0đź‘Ť
I know the thread is pretty old but to answer it :
I found this :
example from the website :
ajax.py
from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def dajaxice_example(request):
return simplejson.dumps({'message':'Hello from Python!'})
html
<input type="button" name="rand" value="Get message from server!" id="rand" onclick="Dajaxice.examples.dajaxice_example(my_callback)">
javascript
function my_callback(data){
alert(data.message);
}
I couldn’t get it to work with “production standards” …
The real magic of now.js is also that you’ve got JS on both side and thus no objects to convert/(un)serialize
I was thinking about a setup like this :
DJANGO <-> NODEJS <-> NOW <-> BROWSER
Django could send objects serialized as json to node who would do the rest …
I guess that would be somewhat tricky … I also thought about going the other way around : meaning getting all django nice features (models,(auto)admin,templates,urls,middleware…)
I couldn’t find anything as nice as django (contrib) admin !! If anyone knows ?
👤dwarfy
Source:stackexchange.com