remove - jquery name csrfmiddlewaretoken




Django+GWT or Jquery (6)

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?


As the lead developer of Nagare, I really encourage you to try it in real on your product, which is the best way to see how Nagare is truely different than the others frameworks like Django, Pylons or Flask. Nagare is components oriented (it shares the same components model than Seaside) and its set of advance features like direct callbacks registration, stateful components, Ajax without to write any Javascript code or the use of continuations makes a Web application looks like a desktop one. In fact we have often found that developers like you, without prior Web experiences, can be quicker to get Nagare because they have nothing to "unlearn".

Talking about reliability, scabability and compatibility, you can check some of our important projects in production today.

For more info, don't hesitate to ask and share your experiences with us.



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.


In my Django/GWT project I do use django-piston to expose Django models via REST API, in JSON format. Look at piston's website for more on how to achieve that http://bitbucket.org/jespern/django-piston/wiki/Home.

Then, on GWT side, you only need to create overlay types for your Django models (DevGuideCodingBasicsOverlay).

I use gwt-dispatch (http://code.google.com/p/gwt-dispatch/) with some REST goodness added to fetch my models from Django backend, but you can use you whatever you want (HttpRequestBuilder), then use GWT JSONParser, and by getting JavaScriptObject and casting, you will get your desired model in GWT. It may seems a little too complicated, but it's not, quite the opposite, it's very comfortable to use.


How to use Django with GWT?

If you want to create a new model, both in GWT and in Django, the easiest way to generate code is to start from a very simple model definition, e.g.

classname
attribute1 type1
attribute2 type2

Parsing that with a little Python is very easy, and so is generating code for both Django and GWT once you parsed the above-like lines. Customization for both Django and GWT will take only a little more work. Taking foreign keys into account is more complicated. Don't forget a tiny little generated method to serialize the objects, e.g. in JSON format.

The first reflex I had was to use introspection in Python, but then I ran into trouble when introspecting foreign key fields in django models. Maybe I should take a look at the code of the django-docs project (available at google code).

Finally, to speed up your GWT+Django development, you can use a http proxy servlet in hosted mode, so that you don't need to compile your GWT stuff every time you want to run your GWT front end with a Django back end. The servlet on http://www.servletsuite.com/servlets/httpproxy.htm will probably do the trick.


I'm trying to pick a framework for a product I'm about to build, and so far I'm leaning toward Nagare… Any thoughts?

I would suggest Django + Pinax. Both are robust and have less learning curve (if you have familiarity with Python).

This should have you a social network up & running within a day or two.

For the front-end use the usual suspects. javascript, css, html. I believe there are some terrific libraries for javascript.