问题
I have a ul
list and a button:
<form>{% csrf_token %}
<div class="list-arrows col-md-1 text-center">
<button class="btn btn-default btn-sm move-left">
<span class="glyphicon glyphicon-chevron-left"></span>
</button>
</div>
</form>
This triggers my ajax request:
function publListChanged()
{
var publs = $('.list-right ul li.active');
Dajaxice.awv_public.reload_stats(Dajax.process, {'publs': '10'})
}
$(function () {
[...]
$('.list-arrows button').click(function () {
var $button = $(this), actives = '';
if ($button.hasClass('move-left')) {
publListChanged();
}
}
}
Currently, for debugging, my method does nothing:
@dajaxice_register
def reload_stats(request, publs):
dajax = Dajax()
return dajax.json()
I get the following error: Dajaxice: Something went wrong.
I have no idea where to look. What should I do?
回答1:
I suspect what went wrong is that you're using the latest version of Django.
Djaxice is a dead project and stopped working after Django 1.6 was released, although the exact version when it broke doesn't appear to be documented. (This inference in this Github issue was the closest I could find to documenting exactly which version broke.)
I once tried upgrading Django in an existing project and found that it broke Djaxice. (This was a while back, so I don't remember what exactly the error was.)
Quoting from the official Github repo: "Should I use django-dajaxice? In a word, No."
Several people have tried to port Djaxice to newer versions of Django, but I've never seen a successful fork. (Maybe a new one was created since I last looked.) I've looked into porting it myself, but found it to be non-trivial.
来源:https://stackoverflow.com/questions/34274753/dajaxice-something-went-wrong