This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 15k traffic Daily!!!

Difference between Null and Blank in Django Model

In Django, many people have some confusion between these two fields in a mannequin Null and Clean, in brief:

  • Null is expounded to a database.
  • Clean is expounded to an HTML type.


Once we set:

  • null=True which signifies that we inform our database that we are able to retailer empty worth as NULL, no-value, with none information, ( Default worth of null is False ).

  • clean=True which signifies that our Kind, our enter could have a required attribute set to false ( by default is true ), then permit the consumer to enter an empty discipline, ( Default worth of clean is False which suggests the required attribute is True ).


You could ask your self when we’ve got string-based fields in a mannequin similar to CharField and TextField, Null and Clean fields are set to True, then Django shops an empty string (" ") in a database as an alternative of Null, WHY 🤔🤔?


  1. First as a result of when our consumer submits an empty worth, our enter will return an empty string ( HTML inputs sort="textual content" are all the time return string values ).

  2. Second, and this necessary is Null in SQL world is handled as Falsy worth and Clean ( empty string ) in Python world can also be Falsy.

Due to this fact, it might be inefficient and redundant for Django to cope with two potential values which might be handled as Falsy values ( No information & Empty String ).


Because the HTML enter returns a string worth on the finish, Django most popular to make use of an empty string (" "), not Null.

The Article was Inspired from tech community site.
Contact us if this is inspired from your article and we will give you credit for it for serving the community.

This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 10k Tech related traffic daily !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?