views:

2199

answers:

3

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?

+4  A: 

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 :)

Van Gale
+1  A: 

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.

Jack M.
Great Jack! Can you share your generator that lookup into models.py? It also handle the extended classes?Now I have realized that for my particular needs, a site catalogue, Jquery and Jquery UI works well, but if later I'll need to add some complex GUI I'll need GWT.
capolise
I would post the code for you, but I'd highly advise looking at a better way to do it. At current I use Perl to parse the .py files. I wrote it before I had a proper understanding of introspecting Django Model files. I'd suggest looking into that, and roll your own.
Jack M.
+8  A: 

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

Rui Vieira