Right, I missed that detail :/
Agree the ModelForm seem a better place to add this validation.
On Wednesday, 8 April 2015 22:22:02 UTC+1, victor menezes wrote:
>
> I liked the idea at first but after couple tests realized that the it will
> alway raise the error on save().
>
> The problem is tha
I liked the idea at first but after couple tests realized that the it will
alway raise the error on save().
The problem is that I can't add any Email without Person, this looks great
but, I also can't add a Person without an Email and so it will never allow
me to add anything.
Maybe I should k
On Wed, Apr 8, 2015 at 12:18 PM, Luis Zárate wrote:
>
> if you know that only have two emails for user and you check his email a lot
> then the cost of join in time and machine resources increase innecessarily
"normalize until it hurts, denormalize until it runs"
here the OP is way, way, behin
I don't know if work with many to many is the best approach, because if you
know that only have two emails for user and you check his email a lot then
the cost of join in time and machine resources increase innecessarily So
knowledge of you requirements determine your db scheme.
Using the first s
+1 for Javier's answer, use a simple Foreign key on the e-mail field, not a
ManyToMany on the Person (M2M allows an email to belong to multiple users).
The Foreign key ensures an e-mail belongs to only 1 user, and that 2 users
cannot have the same e-mail, but lets a user have multiple.
To force
Would it be a bad approach to use a ManyToMany with properties null/blank
False?
class Email(models.Model):
email = models.EmailField(unique=True)
def __unicode__(self):
return self.email
class Person(models.Model):
first_name = models.CharField(max_length=100)
last_name
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, Ja
On Tue, Apr 7, 2015 at 2:20 PM, victor menezes 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 id
8 matches
Mail list logo