3. dajaxproject.com
•
Set
of
easy
to
use
AJAX
libraries
for
django.
•
django-‐dajaxice
•
communica9on
core.
•
send
data
to
your
browser
asynchronously.
•
django-‐dajax
•
manipulate
the
DOM
using
python.
4. @github
Forks Watchers
django-‐dajax 6 110
django-‐dajaxice 10 95
o us, b ut I’m
enor m
It’s not pp y :)
really ha
h@ps://github.com/jorgebas*da/django-‐dajax/
h@ps://github.com/jorgebas*da/django-‐dajaxice/
5. dajaxice
aims
•
Uniform
communica9on
between
the
client
and
the
server.
•
JS
Framework
agnos2c.
•
No
Prototype,
jQuery...
required.
•
Presenta9on
logic
outside
the
views.
•
No
presenta9on
code
inside
ajax
func9ons.
•
Crossbrowsing
ready.
7. Example
from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
@dajaxice_register
def my_example(request):
return simplejson.dumps({'message':'Hello World'})
a fu nction
Ye s. It’s
eturn s json
t hat r
8. Example
functi
on na
me
function on_whatever(){
Dajaxice.example.my_example(my_js_callback);
}
pp name back
a call
9. Example
callback
function my_js_callback(data){
alert(data.message);
}
yo ur s tuff
10. Installa@on
{% load dajaxice_templatetags %}
<html>
<head> auto ma g ically
<title>My base template</title>
... ad d the
e d js *
{% dajaxice_js_import %}
</head> requir
...
</html>
*
It
could/should
be
served
sta*cally
for
produc*on.
15. the
code
from dajax.core.Dajax import Dajax
def assign_test(request):
dajax = Dajax()
dajax.assign('#list li','innerHTML','Hello!')
dajax.add_css_class('#list li','new')
...
return dajax.json()
yo ur ac
t io ns