-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
Currently a field with null=True and blank=False is mapped to a serializer field with required=False. This contradicts Django docs for blank fields:
Field.blank
If True, the field is allowed to be blank. Default is False.
Note that this is different than null. null is purely database-related, whereas blank is validation-related. >If a field has blank=True, form validation will allow entry of an empty value. If a field has blank=False, >the field will be required.
If blank is False, field should be required=True.
A model field with null=True and blank=False is useful when you want to force a user to set a foreign key (blank=False) upon object creation or modification but you want to allow the related object to be deleted with no impact on the object at hand (on_delete=SET_NULL, null=True).