Dajaxproject.com

 Dajaxproject.com

Dajaxproject.com, 5m Lighting talk. Djangocon Europe, Amsterdam (Jun. 2011)

2e19e78ec961cd9c60642ce7fe9f8c68?s=128

Jorge Bastida

May 09, 2011
Tweet

Transcript

  1. dajaxproject.com Jorge  Bas*da @jorgebas*da jorgebas*da.com

  2. dajaxproject.com?

  3. dajaxproject.com •  Set  of  easy  to  use  AJAX  libraries  for

     django. •  django-­‐dajaxice •  communica*on  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 hKps://github.com/jorgebas*da/django-­‐dajax/

    hKps://github.com/jorgebas*da/django-­‐dajaxice/
  5. @github Forks Watchers django-­‐dajax 6 110 django-­‐dajaxice 10 95 hKps://github.com/jorgebas*da/django-­‐dajax/

    hKps://github.com/jorgebas*da/django-­‐dajaxice/ It’s not enormous, but I’m really happy :)
  6. dajaxice  aims •  Uniform  communica*on  between  the  client  and  the

     server. •  JS  Framework  agnos:c. •  No  Prototype,  jQuery...  required. •  Presenta*on  logic  outside  the  views. •  No  presenta*on  code  inside  ajax  func*ons. •  Crossbrowsing  ready.
  7. STFU...  Show  me  the  code

  8. Example from django.utils import simplejson from dajaxice.decorators import dajaxice_register @dajaxice_register

    def my_example(request): return simplejson.dumps({'message':'Hello World'})
  9. Example from django.utils import simplejson from dajaxice.decorators import dajaxice_register @dajaxice_register

    def my_example(request): return simplejson.dumps({'message':'Hello World'}) Yes. It’s a function that returns json
  10. Example function on_whatever(){ Dajaxice.example.my_example(my_js_callback); }

  11. Example function on_whatever(){ Dajaxice.example.my_example(my_js_callback); } app name function name callback

  12. Example function my_js_callback(data){ alert(data.message); }

  13. Example function my_js_callback(data){ alert(data.message); } callback your stuff

  14. Installa:on {% load dajaxice_templatetags %} <html> <head> <title>My base template</title>

    ... {% dajaxice_js_import %} </head> ... </html>
  15. 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.
  16. And  django-­‐dajax?

  17. dajax  =  sugar  to  dajaxice

  18. django-­‐dajax ✦  Manipulate  the  DOM  through  python. ✦  Nearly  0

     js  knowledge  required. ✦  Supports  some  JS  frameworks  like...
  19. django-­‐dajax ✦  Manipulate  the  DOM  through  python. ✦  Nearly  0

     js  knowledge  required. ✦  Supports  some  JS  frameworks  like... coupling boooo
  20. Internally

  21. 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()
  22. 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
  23. the  code function on_whatever(){ Dajaxice.app.assign_test(Dajax.process); }

  24. the  code function on_whatever(){ Dajaxice.app.assign_test(Dajax.process); } Dajax callback

  25. DEMO

  26. Thanks Jorge  Bas*da @jorgebas*da jorgebas*da.com