问题
I have serious problem with Dajax installation. However dajaxice work correctly dajax does not respond.
INSTALLED_APPS = (
...
'dajaxice',
'dajax',
...)
TEMPLATE_CONTEXT_PROCESSORS = ("...
"django.core.context_processors.request",
...)
TEMPLATE_LOADERS = (
...
'django.template.loaders.eggs.Loader',
)
Head section contains those elements:
{% load dajaxice_templatetags %}
src="/static/js/jquery.js"
src="/static/js/functions.js"
src="/static/js/jquery.dajax.core.js"
{% dajaxice_js_import %}
Apart of it, I have ajax.py
in one of my apps with sample functions. Should I do sth more? Do you see any mistakes ?
回答1:
Bit late - but I don't see any obvious mistakes. Perhaps you could first to try to get some information on the problem. Does your settings.py have:
DEBUG = True
you might want to add some loggers to settings.py - e.g:
'dajaxice': {
'handlers': ['file', 'console'],
'level': 'WARNING',
'propagate': True,
},
'dajaxice.DajaxiceRequest': {
'handlers': ['file', 'console'],
'level': 'WARNING',
'propagate': True,
},
}
you also don't state whether or not your ajax.py has imported the required modules, might be worth checking:
from dajax.core import Dajax
from dajaxice.decorators import dajaxice_register
and from the docs dajax requires jQuery 1.6.2 (and above from my experience). What version are you using?
finally - make sure you add the registration decorator to your ajax.py functions, or otherwise register them as per the documentation http://docs.dajaxproject.com/dajaxice/create-my-first-dajaxice-function.html#create-your-ajax-function
For example:
@dajaxice_register
def myexample(request):
return simplejson.dumps({'message': 'Hello World'})
I'm loving Dajax/Dajaxice, although it's allowing me (or I'm allowing myself) to get into a big of a spaghetti bowl of code looping back and forth between python/django & js.
来源:https://stackoverflow.com/questions/11083168/dajax-installation