Django models: difference between null and blank
Fields in Django models take certain arguments. Null and blank are ones that are available to all field types, and are sometimes confusing as to which one means what.
NULL
If True, Django will store empty values as NULL in the database. Default is False.
BLANK
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, form validation will allow entry of an empty value.If a field has
blank=False, the field will be required.
Examples
Good SO discussion: https://stackoverflow.com/questions/8609192/differentiate-null-true-blank-true-in-django
Last updated
Was this helpful?