On Wed, Jan 12, 2011 at 11:19 PM, Andrew Godwin <[email protected]> wrote:
> On 12/01/11 17:54, Daniel Swarbrick wrote:
>> Most of the time, I use POST for forms, but using GET is useful when
>> developing a search form, for example. This is especially true if you
>> want to paginate your results, because you still have all your
>> original form variables in the query string.
>>
>> CBV FormView get_form_kwargs() only populates form_kwargs data if the
>> request is POST or PUT, which means that a GET form will never have
>> form.is_valid() == True, even thought the supplied query string may
>> indeed validate all form fields.
>>
>> Is this by design, or an oversight?
>
> This is, at least in my view, by design - it's good web behaviour to not
> use GET to modify data, or otherwise do things that forms usually end up
> doing.
>

True. Not all forms do that though. The OPs case seems reasonable
enough, all 'search'-like forms *should* be submitted through GET
requests. Examples from django's own websites include the custom
google search box on docs.djangoproject.com, the TRAC ticket search on
code.djangoproject.com, etc.

It seems strange to say that these sorts of forms are not usable in a
FormView without modification. Perhaps some additional documentation
should be added to [1] to document this limitation.

Cheers

Tom

[1] http://docs.djangoproject.com/en/dev/ref/class-based-views/#formview

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

Reply via email to