Submitting a form with GET using Django's FormView
Let me just put it out there.  I'm one of those people who think submitting form data with GET is a perfectly reasonable thing to do when implementing search functionality.  If you use Django and think like I think, then you should know the following:  This behavior is not currently implemented for Django's generic FormView (dpkg -l python-django tells me I'm using 1.3-2).  Submitting a form using GET will provide no form validation.  Luckily for us, Django's class-based views were designed to be customized and extended,  and thanks to Daniel Swarbrick, we have some code to do just that:
def get_form_kwargs(self): kwargs = {'initial': self.get_initial()} if self.request.GET: kwargs['data'] = self.request.GET return kwargs
This method can either be provided by a shiny-new MixIn class or it can be added as an override to an existing FormView. Â If you're asking me for my opinion on which way to go, then I'll give it: I prefer the MixIn approach because it's simple and reusable :)
















