Django unique_together error and validation

Posted by zubinmehta on Stack Overflow See other posts from Stack Overflow or by zubinmehta
Published on 2010-05-30T18:45:27Z Indexed on 2010/05/30 18:52 UTC
Read the original article Hit count: 477

class Votes(models.Model):  
    field1 = models.ForeignKey(Blah1)  
    field2 = models.ForeignKey(Blah2)  
    class Meta:  
            unique_together = (("field1","field2"),)

I am using this code as one of my models. Now i wanted to know two things:
1. It doesn't show any error and it saved an entry which wasn't unique together; So is the piece of code correct?
2. How can the unique_together constraint be be validated?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models