Reputation: 1208
I'm running Django (1.4.3) with dajaxice (0.5.4). I have a file ajax.py
with my functions in the main project folder called prj
, which looks like:
from dajax.core import Dajax
from dajaxice.decorators import dajaxice_register
from django.utils import simplejson
from dajaxice.core import dajaxice_functions
from django.core.urlresolvers import reverse, resolve
def getContent(request, *args, **kwargs):
url = kwargs['url']
try:
v = resolve(url)
except:
data = []
data.append(('some','data'))
return simplejson.dumps(data)
dajaxice_functions.register(getContent)
I ran python manage.py collectstatic
, and I get the following output:
Copying '/tmp/tmpm8OlOw'
However, the dajaxice.core.js
generated does not have my function getContent
at all. Where am I going wrong? I have dajaxice installed properly and everything, I hope.
Upvotes: 1
Views: 986
Reputation: 139
You need to register you function with dajaxice either using @dajaxice_register decorator or other methods mention in the documentation.
http://django-dajaxice.readthedocs.org/en/latest/quickstart.html#create-your-first-ajax-function
Upvotes: 0
Reputation: 3680
Seems you forgot to call dajaxice_autodiscover()
from urls.py
(this is the place recommended by dajaxice author)
this call will load ajax.py module and make it's method discoverable by JS code generator
Upvotes: 0