title: how to insert data into database using forms in Django
body: <p>models.py</p>
  
  <pre><code>class Author(models.Model):
      author_id = models.AutoField(primary_key=True)
      first_name = models.CharField(max_length=30)
      last_name = models.CharField(max_length=40)
      email = models.EmailField()
      age=models.IntegerField()
  
      class Meta:
      db_table=u'Author'
  
      def __unicode__(self):
          return u"%d %s %s %s %d" % (self.pk, self.first_name, self.last_name, self.email,self.age)
  
  
  
  class Book(models.Model):
      book_id=models.AutoField(primary_key=True,unique=True)
      book_name=models.CharField(max_length=30)
      publisher_name=models.CharField(max_length=40)
      author=models.ForeignKey(Author)
  
      class Meta:
          db_table = u'Book'
  
      def __unicode__(self):
          return u'%d %s %s' % (self.pk, self.book_name, self.publisher_name)
  </code></pre>
  
  <p>my forms.py</p>
  
  <pre><code>class AuthorForm(forms.ModelForm):
  
      class Meta:
          model = Author
          fields = ['author_id','first_name','last_name','email','age']
  
  class BookForm(forms.ModelForm):
  
      class Meta:
          model = Book
          fields=['book_id','book_name','publisher_name','author_id']
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def addbook(request):
  
      log.debug("test....")
      form = BookForm     
      if request.POST:
          form = BookForm(request.POST)
          if form.is_valid():
              form.save()
              return render_to_response('addbook.html',{'form': form} , context_instance=RequestContext(request)) 
  </code></pre>
  
  <p>I am trying to insert the data into database and displaying it through a template.But i ma not sure the code what i used are correct becaues i am getting lots of error.eg recently i got the error as"ValueError: ModelForm has no model class specified.".</p>
  
  <p>But after rectifying this error again errors are coming and not able to save the data to database.</p>
  
  <p>Please check the code's are correct,if not give me the correct code for doing the same.Acutally i think some problem in the views.py.Please check everything and get me the cooect one.</p>
  
  <p>Thanks.</p>