Thanks for the help, I end up doing it was easy to implement the email as TabularInline inside the Person form in the Admin but how would you make mandatory to have at least one e-mail? Should I validate inside the save() method of Person class?
On Tuesday, April 7, 2015 at 3:55:26 PM UTC-4, Javier Guerra wrote: > > On Tue, Apr 7, 2015 at 2:20 PM, victor menezes <menezes...@gmail.com > <javascript:>> 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/14e85fe3-ff59-4568-82b3-aa40ae488b94%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.