Django null = True and the difference between the blank = True

We encountered a problem today:

Restframework framework developed, the database creates a model of the properties are as follows:

    remarks = models.CharField(verbose_name=u"描述", max_length=500, null=True)
remarks must pass a non-data, so there is no increase in the verification of the serializer, I felt no problem, but when submitting data remarks to an empty string, an error is 'verification fails, remarks can not be empty'. However, when there is no error value does not pass remarks. 
Later, after some searching to find, found to be blank = True is no reason plus.
The final modified:
    remarks = models.CharField(verbose_name=u"描述", max_length=500, null=True, blank = True)

Submit again, even if the remark is an empty string, success can still be submitted.
Summarized as follows:

1, serializer does not add verification, it is possible to not pass through the remarks value, then the default cut is null. This is null = True at work, null and database are related, when reamrks is empty, it will be stored as NULL. 
2, blank = True is a page form validation related, which indicates the corresponding page of the form can be empty, can not fill anything.

Guess you like

Origin www.cnblogs.com/wangyingblock/p/11016369.html