What is the difference between null=True and blank=True in Django?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
null=True
setsNULL
(versusNOT NULL
) on the column in your DB. Blank values for Django field types such asDateTimeField
orForeignKey
will be stored asNULL
in the DB.blank
determines whether the field will be required in forms. This includes the admin and your custom forms. Ifblank=True
then the field will not be required, whereas if it’sFalse
the field cannot be blank. few examples:null=True/False
related to databaseblank=True/False
related to form validation