简体   繁体   English

Dajax安装

[英]Dajax installation

I have serious problem with Dajax installation. 我在安装Dajax时遇到严重问题。 However dajaxice work correctly dajax does not respond. 但是dajaxice可以正常工作dajax无法响应。 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. 除此之外,我的一个带有示例功能的应用程序中有ajax.py Should I do sth more? 我应该做更多吗? Do you see any mistakes ? 你看到任何错误吗?

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: 您的settings.py是否具有:

DEBUG = True 

you might want to add some loggers to settings.py - eg: 您可能想向settings.py添加一些记录器-例如:

'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: 您也没有说明您的ajax.py是否已导入所需的模块,可能值得检查:

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). 并且从文档dajax需要jQuery 1.6.2(根据我的经验)。 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 最后-确保将注册装饰器添加到ajax.py函数中,或者按照文档http://docs.dajaxproject.com/dajaxice/create-my-first-dajaxice-function.html#create-进行注册您的ajax功能

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. 我爱Dajax / Dajaxice,尽管它允许我(或者我允许自己)进入一大堆意粉代码,它们在python / django和js之间来回循环。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM