The Django models API contains two options which are similar in nature. These options are known as blank and null.

The main difference between blank and null is as follows:

  • Blank: Relates to database-validation.

    So, for example: by setting Blank = True we are telling our database that it is okay for a specific field in our model to be blank.

    If however, we set Blank = False this will not allow our database field to be blank.

  • Null: Relates to form-validation.

    So, for example: by setting Null = True we are telling our forms in Django that is is okay for a specific field to be empty.

    If however, we set Null = False this will not allow our form field to be empty. So we will need to add some data into our field. This field may be an address or phone number based field.

An easier way to clarify these differences is think of blank as operating in our database fields (database-level) and null operating in our form-validation fields (application-level).

Here is an example of how these options can be implemented within a Django model:

class Product(models.Model):
    description = models.TextField(max_length=400, blank=True, null=True)