title: How do I use CreateView with a ModelForm
body: <p>I get an error in my class AuthorCreateForm when I submit my form.
  NameError
  self is not defined</p>
  
  <p>How do I use a CreateForm?</p>
  
  <p>I have created a class in my Author.py file</p>
  
  <pre><code>from django.views.generic import TemplateView, ListView, CreateView
  from books.models import Author, Publisher, Book
  from books.forms import AuthorForm
  
  class AuthorCreateView(CreateView):
      objAuthorForm = AuthorForm(self.request.POST)
  
      if(objAuthorForm.save()):
          success = "Form saved!"
      else:
          error = "There was an error!"
  </code></pre>
  
  <p>and I have a html template which submits to /Author/Create</p>
  
  <p>and I have the following line in my urls.py</p>
  
  <pre><code>('^authors/create/$', Author.AuthorCreateView.as_view()),
  </code></pre>
  
  <p>I render the form at this URL</p>
  
  <pre><code>('^authors/new/$', TemplateView.as_view(template_name="author_new.html")),
  </code></pre>
  
  <p>I find the class based views confusing, does anyone have a good tutorial on how to use it for CRUD operations?</p>
  
  <p>Thanks</p>