djangocon dajaxproject lightning talk
DESCRIPTION
My djangocon dajaxproject lightning talk.TRANSCRIPT
dajaxproject.comJorge Bas*da@jorgebas*da
jorgebas*da.com
dajaxproject.com?
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.
@github
Forks Watchers
django-‐dajax 6 110
django-‐dajaxice 10 95
h@ps://github.com/jorgebas*da/django-‐dajax/h@ps://github.com/jorgebas*da/django-‐dajaxice/
It’s not enormous, but
I’m
really happy :)
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.
STFU... Show me the code
Example
from django.utils import simplejsonfrom dajaxice.decorators import dajaxice_register
@dajaxice_registerdef my_example(request): return simplejson.dumps({'message':'Hello World'})
Yes. It’s a function
that returns json
Example
function on_whatever(){ Dajaxice.example.my_example(my_js_callback);}
app name
function name
callback
Example
function my_js_callback(data){ alert(data.message);}
callback
your stuff
Installa@on
{% load dajaxice_templatetags %}
<html> <head> <title>My base template</title> ... {% dajaxice_js_import %} </head>...</html>
automagically
add the
required js *
* It could/should be served sta*cally for produc*on.
And django-‐dajax?
dajax = sugar to dajaxice
django-‐dajax
✦ Manipulate the DOM through python.
✦ Nearly 0 js knowledge required.
✦ Supports some JS frameworks like...
couplingboooo
Internally
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()
your actions
the code
function on_whatever(){ Dajaxice.app.assign_test(Dajax.process);}
Dajax callback
DEMO
Thanks
Jorge Bas*da@jorgebas*da
jorgebas*da.com