Sunday, January 3, 2016

EmailField: unable to make it mandatory?

Hello all and happy new year,

with Django 1.7, i have this model:
class Subscription(models.Model):
email = models.EmailField(max_length=75)
created_by = models.ForeignKey(User)

sub = Subscription.objects.create(created_by=self.user)
this does not product an error due to email missing.

I also tried:
email = models.EmailField(max_length=75, null=False, blank=False)
without success

The database is postgresql, the command "manage.py sql" shows:
CREATE TABLE "eventsmgmt_subscription" (
"email" varchar(75) NOT NULL,

in fact, the email is filled with a null string ''.

How can i deal with this?


Thanks in advance for help,

--
Gérard Henry

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5689FCC0.40001%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment