mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-26 16:30:41 +03:00
Deal with 1.9's differing null behavior on reverse relationships and m2m
This commit is contained in:
parent
b51c1ff0b0
commit
8db6367188
|
@ -233,9 +233,11 @@ def get_relation_kwargs(field_name, relation_info):
|
||||||
# No further keyword arguments are valid.
|
# No further keyword arguments are valid.
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
if model_field.has_default() or model_field.blank or model_field.null:
|
null = model_field.null and not to_many
|
||||||
|
|
||||||
|
if model_field.has_default() or model_field.blank or null:
|
||||||
kwargs['required'] = False
|
kwargs['required'] = False
|
||||||
if model_field.null:
|
if null:
|
||||||
kwargs['allow_null'] = True
|
kwargs['allow_null'] = True
|
||||||
if model_field.validators:
|
if model_field.validators:
|
||||||
kwargs['validators'] = model_field.validators
|
kwargs['validators'] = model_field.validators
|
||||||
|
|
Loading…
Reference in New Issue
Block a user