Blank stores an empty string in the database.
To set a field, enter blank = true. The default value is blank = false (required );
Null represents null in the database, rather than an empty string.
If you need to set the field to NULL: null = true, the default value is null = false (the field must be filled in );
Note:
The date type (datefield, timefield, datetimefield) and numeric type (integerfield, decimalfield, floatfield) cannot accept null strings. Therefore, if you want to set the fields of the two types to be null, you must set both null = true and blank = true;
Summary (the summary is from the blog site ccorz)
Null is used for databases. If null = true, this field of the database can be null.
Blank is for a form. If blank is set to true, this field can be left blank when your form is filled in. For example, when you add a model record to the admin interface. This field is not in bold.
Zero _ WYF
Link: https://www.jianshu.com/p/108697dfb899
Source: Simplified book
The copyright of the simplified book belongs to the author. For any form of reproduction, please contact the author for authorization and indicate the source.
Differences between null and blank in Django Models