dajaxproject.com
      Jorge	
  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



                                              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/
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 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
Example


                        functi
                                 on na
                                      me
function on_whatever(){
    Dajaxice.example.my_example(my_js_callback);
}



             pp name                    back
           a                        call
Example


               callback


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



       yo ur s tuff
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.
And	
  django-­‐dajax?
dajax	
  =	
  sugar	
  to	
  dajaxice
django-­‐dajax

                                                      co upl
                                                             ing
                                                       bo o o o
	
  Manipulate	
  the	
  DOM	
  through	
  python.
✦


	
  Nearly	
  0	
  js	
  knowledge	
  required.
✦


	
  Supports	
  some	
  JS	
  frameworks	
  like...
✦
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()
                      yo ur ac
                              t io ns
the	
  code




function on_whatever(){
    Dajaxice.app.assign_test(Dajax.process);
}



                                    Dajax
                                   callback
DEMO
Thanks
  Jorge	
  Bas*da
  @jorgebas*da
jorgebas*da.com

djangocon dajaxproject lightning talk

  • 1.
    dajaxproject.com Jorge  Bas*da @jorgebas*da jorgebas*da.com
  • 2.
  • 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.
  • 6.
  • 7.
    Example from django.utils importsimplejson 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 {% loaddajaxice_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.
  • 11.
  • 12.
    dajax  =  sugar  to  dajaxice
  • 13.
    django-­‐dajax co upl ing bo o o o  Manipulate  the  DOM  through  python. ✦  Nearly  0  js  knowledge  required. ✦  Supports  some  JS  frameworks  like... ✦
  • 14.
  • 15.
    the  code from dajax.core.Dajaximport 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
  • 16.
    the  code function on_whatever(){ Dajaxice.app.assign_test(Dajax.process); } Dajax callback
  • 17.
  • 18.
    Thanks Jorge  Bas*da @jorgebas*da jorgebas*da.com