On Tue, Apr 7, 2015 at 2:20 PM, victor menezes <menezes.vic...@gmail.com> wrote:
> What would be the best way to make a model with two e-mail fields uniques? I
> was thinking about writing some validation in the save() method but would
> like to know whether Django has some built-in way to deal with it.


it's a very bad idea to have plurality by adding a number of similar
fields.  instead, you should have a related table

class Person(models.Model):
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)

class Email(models.Model):
    person = models.ForeignKey(Person)
    email = models.EmailField(unique=True)


-- 
Javier

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFkDaoTruUKGUxS0nKn6zyQFCy%2BY%2BY%2B4-kOBTOAgwOWQHR5AtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to