Django models avoid duplicates

Posted by Hulk on Stack Overflow See other posts from Stack Overflow or by Hulk
Published on 2010-06-16T11:58:56Z Indexed on 2010/06/16 12:12 UTC
Read the original article Hit count: 407

In models,

  class Getdata(models.Model):
   title = models.CharField(max_length=255)
   state = models.CharField(max_length=2, choices=STATE, default="0")
   name = models.ForeignKey(School)
   created_by = models.ForeignKey(profile)

  def __unicode__(self):
   return self.id()

In templates

     <form>

     <input type="submit" save the data/>
     </form> 

If the user clicks on the save button and the above data is saved in the table how to avoid the duplicates,i.e, if the user again clicks on the same submit button there should not be another entry for the same values.Or is it some this that has to be handeled in views

Thanks..

© Stack Overflow or respective owner

Related posts about python

Related posts about django