Db/Models: distinction btw "null" and "blank"
|Reported by:||MixedContent||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In the 1.3 doc (https://docs.djangoproject.com/en/1.3/topics/db/models/), some distinctions are drawn between allowing/disallowing null in the database and allowing/disallowing blank on data-entry:
If True, Django will store empty values as NULL in the
database. Default is False.
If True, the field is allowed to be blank. Default is False.
Note that this is different than null. null is purely
database-related, whereas blank is validation-related. If a field
has blank=True, validation on Django's admin site will allow entry
of an empty value. If a field has blank=False, the field will be
This leaves me, and I suspect at least some other newbies, wondering what happens if 1. blank is allowed on data-entry, 2. null is not allowed in the database, and 3. a user leaves a field blank. Is the input rejected? Is a default, non-null value inserted? Are developers advised not to allow conditions 1. and 2. both to apply in the same instance?
It occurs to me that this might have been intentionally "left as an exercise for the reader," but I'd suggest that approach would be more correct in the tutorial than in the ref.