Reputation: 31
I just set up Django and Dajaxice and I am having trouble getting it to work after closely checking the documentation for both Django set up and Dajaxice.
After some research here at stack overflow the only thing I found was to make sure that I had dajaxice_autodiscover() in my urls.py, which I do. Here is my ajax.py in my TimeBlendApp:
from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def sayhello(request):
return simplejson.dumps({'message':'Hello World'})
and my html page
{% load dajaxice_templatetags %}
<html>
<head>
<script type="text/javascript">
function my_js_callback(data){
alert(data.message);
}
</script>
<title>My base template</title>
{% dajaxice_js_import %}
</head>
<body>
<button onclick="Dajaxice.TimeBlendApp.sayhello(my_js_callback);">Click me</button>
</body>
</html>
The error I get is
FunctionNotCallableError at /dajaxice/TimeBlendApp.sayhello/
TimeBlendApp.sayhello
Request Method: GET
Request URL: http://127.0.0.1:8000/dajaxice/TimeBlendApp.sayhello/
Django Version: 1.5.1
Exception Type: FunctionNotCallableError
Exception Value:
TimeBlendApp.sayhello
Exception Location: C:\Python27\lib\site-packages\dajaxice\views.py in dispatch, line 60
Upvotes: 3
Views: 807
Reputation: 1732
You must run
python manage.py collectstatic
everytime you change or add the dajax/dajaxice functions.So dajaxice can create its own javascript libraries in static directory.
Upvotes: 2