Dajax installation

别说谁变了你拦得住时间么 提交于 2020-01-17 04:08:29

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!