Hi,

This is my model -

class Tag(models.Model):
    user = models.ForeignKey(get_user_model())
    name = models.CharField(max_length = 300)
    color = models.CharField(max_length = 10)
    icon = models.CharField(max_length = 50)

    class Meta:
        unique_together = ("user", "name")

    def __unicode__(self, ):
        return self.name

The problem I am facing is -
I made 2 Tag objects =
1) Tag(user = jon, name = 'man')
2) Tag(user = jon, name = 'Man')

The first gets saved, but while saving the second, I am getting the error -
IntegrityError: (1062, "Duplicate entry '2-Man' for key 'user_id'")

I deleted the database, created it again and ran 'syncdb'. Still, I am
getting the same error. Is this because of unique_together ?
How can I bypass this ?

Thanks,
Parin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to