On Wed, 2009-01-28 at 11:48 +0200, Donn wrote:
> On Wednesday, 28 January 2009 09:46:09 Paul Johnston wrote:
> > Is it possible to use more complex form widgets 
> In my *very* limited experience, I would say yes. 
> 
> The widgets are really javascript and all your Django view needs to worry 
> about is what comes back via GET or POST.

Yes. That's the key to the whole issue.

> Fetch the data from them, parse it, stuff it into a form object, validate it 
> and then save it.
> 
> Not easy, and it takes a lot of to and fro to get data in dict and JSON all 
> talking to each other.

It's actually really easy with most Javascript widgets.

Step 1: write your form so that it works without Javascript (pretty much
a required step anyway).

Step 2: Write the onload() or "document ready" method for your page to
insert the appropriate Javascript widgets for the correct elements. This
assumes you have familiarity with Javascript, but if you're using
Javascript code for your HTML forms, that's kind of assumed. Django
doesn't remove the need to know HTML and Javascript.

Step 3: Sit back. Have a cool or warm drink of choice.

Javascript widgets are just a presentational wrapper, implemented at the
browser side. The changes required on the Django side are close to zero,
since the widgets still provide data in "regular" formats. You might
need to tweak the validation for a particular django.contrib.forms field
appropriately for the data that's passed in, but that's generally not
too hard.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to