Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django + GWT or Jquery

I have made a complex models structure in django. I had planned to render this structure using GWT, but with python the option to communicate whit it are: - using JSON and in this case I have to duplicate the models structure in javascript objects (see gwt tutorial). - python-gwt-rpc is a remote procedure call library compatible with gwt, but it seems to me that it's not easy to integrate with django models, and the outdated documentation doesn't help me.

The alternative I considering is using the Django template system to render my pages with some Jquery UI plugins and the method suggested in this post to retriving html data without deal with JSON objects because I think that dealing with it is a nightmare because in my structure when the data changes also the interface could be drammatically change.

So I think that with GWT I have to duplicate the django models in javascript objects but I have supported by the java subclasses system. In the second solution I reuse the django models and use the django template system then I able to make server side check, but neither a cool GWT interface neither the lightweight Json call to update pages.

What is yuor approach on this issue?

like image 393
capolise Avatar asked Jun 13 '09 08:06

capolise


3 Answers

Have you considered pyjamas?

For me, it's the best of both worlds. You use, as usual, the Django back-end but can easily use JSON RPC services from your pyjamas code.

You code the front-end pretty much like in GWT, but in Python instead of Java.

Here is a brief tutorial: http://gdwarner.blogspot.com/2008/10/brief-pyjamas-django-tutorial.html

like image 188
Rui Vieira Avatar answered Oct 04 '22 14:10

Rui Vieira


I think you need to make your decision based the usual factors: how much time do you have to develop your app, and what are the best set of tools to get the development done in that time.

If you have made the decision that Django is your server-side framework (which is my favorite choice) then it seems pretty clear that jQuery, Dojo, etc. are probably going to integrate easier with your Django.

On the other hand, if you have more time and especially if you could open-source the Django interface parts, then it would be very cool to write some code that could hook into Django internals and generate the necessary Javascript to seamlessly interface with GWT and not violate DRY.

So in short, if you have to get the app done go with jQuery. If you have more time and want some kudos then develop a nice seamless library for Django that will render the proper HTML + Javascript from Django models and forms that will integrate with GWT.

Just my opinion :)

like image 40
Van Gale Avatar answered Oct 04 '22 16:10

Van Gale


I've actually crossed this exact bridge, and unfortunately I found it is best to make the client side objects in GWT. Luckily, however, this is easily done using JavaScript Overlays and a little code generator.

My code generator looks at the models.py file and rips out all of the pertinent fields before plopping them into the .java files for GWT. Once you have this, implementing your new objects is pretty easy.

like image 35
Jack M. Avatar answered Oct 04 '22 14:10

Jack M.