mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 04:20:12 +03:00
Field 'allow_null' implies 'default=None'
This commit is contained in:
parent
b949629318
commit
ddeecdec51
|
@ -311,6 +311,10 @@ class Field(object):
|
|||
self._creation_counter = Field._creation_counter
|
||||
Field._creation_counter += 1
|
||||
|
||||
# If `default` is unset, then use `None` when allow_null is `True`.
|
||||
if default is empty and allow_null:
|
||||
default = None
|
||||
|
||||
# If `required` is unset, then use `True` unless a default is provided.
|
||||
if required is None:
|
||||
required = default is empty and not read_only
|
||||
|
|
Loading…
Reference in New Issue
Block a user