>
> i looked into database directly:
> foo=> \d eventsmgmt_subscription
> Table «
> public.eventsmgmt_subscription »
> Colonne | Type | Modificateurs
>
> ---------------------+--------------------------+--------------------------------------------------------------------------
> id | integer | non NULL Par défaut,
> nextval('eventsmgmt_subscription_id_seq'::regclass)
> created_by_id | integer | non NULL
> email | character varying(75) | non NULL
>
> as you can see, "not NULL" is in the table
>
>
> thanks for reply,
>
> --
> Gérard Henry
>
*smacks forehead* Yes, you're right. I apologize for the red herring. I
forgot that we're dealing with a CharField.
It dawned on me as soon as I read this. TheCharField (and others) will use
an empty string ("") as their 'empty' value, as opposed to None/null. This
is a design decision of Django:
https://docs.djangoproject.com/en/1.9/ref/models/fields/#null
That means if you want to enforce having any CharField to be required at
the model level, you'll need to define a custom validation function to do
so.
https://docs.djangoproject.com/en/1.9/ref/models/fields/#validators
https://docs.djangoproject.com/en/1.9/ref/validators/
In general, though, this type of validation is usually done at the form and
sometimes view level where end-user input is filtered before being sent to
the model code, since the models can sometimes be populated by other
sources such as a CSV import that may have different requirements than a
standard end-user. But that may not be applicable in your case.
-James
--
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 [email protected].
To post to this group, send email to [email protected].
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/CA%2Be%2BciVMNMs5t20FV0%2BoUGLZuCVj4NvtH3DH_AHjwAhmwjjmxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.