I have this model:
class blog(models.Model):
user = models.ForeignKey(User)
mail = models.EmailField(max_length=60, null=False, blank=False)
name = models.CharField(max_length=60, blank=True, null=True)
I want that (user,email) are unique togheter. For example:
This is allowed:
-
1, hello@hello.com, myblog
-
2, hello@hello.com, secondblog
This is NOT allowed:
-
1, hello@hello.com, myblog
-
1, hello@hello.com, secondblog
Is this possible in Django ?
It’s possible, see: model options,
http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together