title: Creating a generic search view in Django
body: <p>I am struggling to create my custom generic view in django to easily create search pages for certain models. I'd like to use it like this:</p>
  
  <pre><code>class MyModelSearchView(SearchView):
      template_name = 'path/to/template.html'
      model = MyModel
      fields = ['name', 'email', 'whatever']
  </code></pre>
  
  <p>which will result in a view that returns a search form on GET and both form and results on POST.
  The <code>fields</code> specifies which fields of <code>MyModel</code> will be available for a user to search.</p>
  
  <pre><code>class SearchView(FormView):
      def get_form(self, form_class=None):
          # what I'v already tried:
          class SearchForm(ModelForm):
              class Meta:
                  model = self.model
                  fields = self.fields
          return SearchForm()
  
      def post(self, request, *args, **kwargs):
          # perform searching and return results
  </code></pre>
  
  <p>The problem with the code above is that form will not be submitted if certain fields are not be properly filled. User should be allowed to provide only part of fields to search but with the code I provided the form generated with <code>ModelForm</code> prevents that (for example because a field in a model cannot be blank). </p>
  
  <p>My questions are: </p>
  
  <ul>
  <li>Is it possible to generate a form based on a model to omit this behaviour?</li>
  <li>Or is there any simpler way to create <code>SearchView</code> class?</li>
  </ul>
  
  <p>I don't want to manually write forms if it's possible. </p>