[Django]-What does blank=True mean in the context of *Integer fields at Django?


From the documentation:

If a field has blank=True, validation on Django’s admin site will allow entry of an empty value.

And from the null documentation:

Note that empty string values will always get stored as empty strings, not as NULL. Only use null=True for non-string fields such as integers, booleans and dates. For both types of fields, you will also need to set blank=True if you wish to permit empty values in forms, as the null parameter only affects database storage (see blank).

So blank=True basically affects only the forms. It allows to have empty form fields. But you also have to set null=True for non- string fields if you really want to allow empty values in the database as “no value” or “empty” means NULL in the database for non-string fields (for string fields, an empty value is just the empty string '' which is different from NULL).


It means that you don’t have to enter a value for the field in a form. (for example when you are using the django admin interface).

It’s different from null because, blank=True might mean that when you don’t enter a value, the default value (for example 0) is used, but null=True indicates that you can also store None in the field.

Look at the documentation:


Leave a comment