views:

22

answers:

1

Hi, I would like to create a widget for use in Django Forms. There is a problem though: i don't know how to make it properly work on a mobile. I'm wanting to create something like this:

Send message to: search-box-here search

and pressing search will post the page, but not actually submit the form at all. instead the widget will perform a search of friends, and return them in a list like this:

Send message to: search-box-here search

Add Person Bob Smith

Add Person John Smith

Does anyone know how I would get the bare-bones of doing this. I know I can do this with javascript, but most mobile web browser do not support JavaScript at all, never mind any AJAX tech.

Joe

A: 

Mobile browsers are so limited, look at how gmail does it for example. It shows you top 10 recent recipients and text box to search for others.

Dmitry Shevchenko
How do i do this with django forms?
Joe Simpson
i would have a form with ModelChoiceField for "top recipients" and charfield for searching. On page submit check if anything in choice field was checked OR (if none) do a search by text and put results into choice field again. There's nothing special about the form but the logic behind it in view.
Dmitry Shevchenko
and i would just not validate the form?
Joe Simpson
why not? if there are no input in textfield and checked items in choice field - i think that tells you that user selected recipients
Dmitry Shevchenko
I've actually made it work properly how I want. I've just subclassed the Form class and like added magic to the fields. :)
Joe Simpson