开发者

How to have a Dajaxice ajax.py file for common ajax calls across a Django project

Is it possible to have a Dajaxice ajax.py file in the root directory of a Django project that handles ajax calls co开发者_如何学JAVAmmon to more than one app. In other words, an ajax.py file outside of a particular app.

Thanks


If you want to share common functions, you can have them eiter in a ajax.py of a specififc application and import them from the other applications or have it in the root directory and import it from there:

DJANGODIR/ajax.py:

from django.utils import simplejson

def helloworld(request, name, id):
    return simplejson.dumps({'message':'hello %s' % name})

DJANGODIR/my_app/ajax.py:

from DJANGODIR.ajax import helloworld
from dajaxice.core import dajaxice_functions

dajaxice_functions.register(helloworld)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜