tags:

views:

18

answers:

1

Hi,

Is it possible to have a Dajaxice ajax.py file in the root directory of a Django project that handles ajax calls common to more than one app. In other words, an ajax.py file outside of a particular app.

Thanks

A: 

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)
Andre Bossard