title: Validating a form in a get request, how?
body: <p>in my way of perfectionism, I'm here to ask more questions about the not-so-well-documented class-based views.</p>
  
  <p>I spend like 5 hours learning about class-based views, lurking into the code and I got a question.</p>
  
  <p>Maybe what I'm trying to do is stupid, and if so, just say that.</p>
  
  <p>I will put a simple example:</p>
  
  <pre><code>class SearchFormView(FormView):
      template_name = 'search/search.html'
      form_class = SearchForm
  
      def get(self, request, *args, **kwargs):
          form = SearchForm(self.request.GET or None)
          if form.is_valid():
              self.mystuff = Stuff.objects.filter(title__icontains=form.cleaned_data['query'])[:10]
  
          return super(SearchFormView, self).get(request, *args, **kwargs)
  </code></pre>
  
  <p>This is a perfect valid class (it is, right?).</p>
  
  <p>You have a form, and you make a GET request with a query parameter.</p>
  
  <p>Works like a charm.</p>
  
  <p>But lets imagine... I validate the query input to prevent some type of attack and I see that the query is malicious so I put a validation error.</p>
  
  <p>With the old functions, I have a form instance (empty) and I put data in it and validation errors if needed. I always return that instance, if empty (first request) or if it filled with errors (the case of the malicious query).</p>
  
  <p>The problem is with class-based views. In my get method I work with an extra instance of <em>SearchForm</em> so if I put validation stuff would be there and if I call <em>get</em> on the <em>father</em> it will use the instance on "form_class" that would be empty.</p>
  
  <p>So, I think that there should be a way where I use the same form always, I mean: I call the request method, I pick the form_class (not create a new form), pass the data, validate and the father will return that form with the validation stuff.</p>
  
  <p>Im not sure if I explained this correctly. So in short, Im creating a copy of the form in the get but I return the <em>father get</em> who have another copy that will be empty, so my when I display the template, there will be no errors because the form sended is empty.</p>
  
  <p>Any ideas? Thanks.</p>