title: How to configure Django generic view for both GET and POST using model form
body: <p>I want to create a view function + template that displays a simple form (derived from a user model) and also captures the form submission. How do I do this using generic views in Django?</p>
  
  <p>My user model is:</p>
  
  <pre><code>class User(models.Model):
     email = models.EmailField(unique=True)
     name = models.CharField(max_length=100)
  </code></pre>
  
  <p>I only need to capture the email field in the form.</p>
  
  <p>I think there must be a simple way to do this using generic forms, however I'm not sure which one to use nor how to do it. The only other ways I know how to do it are:</p>
  
  <p>1) Create UserForm explicitly and a single view function separating POST and GET requests. E.g., :</p>
  
  <pre><code>def contact(request):
     if request.method == 'GET':
         # display UserForm
          ....
     elif request.method == 'POST':
         # process form submission
          ....
  </code></pre>
  
  <p>2) Create two views (with seperate URLs) - one using generic view to display form and another view to receive form submission e.g.,:</p>
  
  <pre><code>class contact(generic.DetailView):
     # display form from User model
     model = User
     ....
  
  def submit(request):
     # process form submission
      ....
  </code></pre>
  
  <p>So, my two questions are:</p>
  
  <ul>
  <li>can and how should this be implemented using ONLY a generic view?</li>
  <li>which generic view should be used?</li>
  </ul>