mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 18:09:59 +03:00
move limit_choices_to above other check to avoid conflicts
This commit is contained in:
parent
7954c03cbf
commit
7fb879c9af
|
@ -249,6 +249,10 @@ def get_relation_kwargs(field_name, relation_info):
|
||||||
if to_field:
|
if to_field:
|
||||||
kwargs['to_field'] = to_field
|
kwargs['to_field'] = to_field
|
||||||
|
|
||||||
|
limit_choices_to = model_field and model_field.get_limit_choices_to()
|
||||||
|
if limit_choices_to:
|
||||||
|
kwargs['queryset'] = kwargs['queryset'].filter(**limit_choices_to)
|
||||||
|
|
||||||
if has_through_model:
|
if has_through_model:
|
||||||
kwargs['read_only'] = True
|
kwargs['read_only'] = True
|
||||||
kwargs.pop('queryset', None)
|
kwargs.pop('queryset', None)
|
||||||
|
@ -266,9 +270,6 @@ def get_relation_kwargs(field_name, relation_info):
|
||||||
# If this field is read-only, then return early.
|
# If this field is read-only, then return early.
|
||||||
# No further keyword arguments are valid.
|
# No further keyword arguments are valid.
|
||||||
return kwargs
|
return kwargs
|
||||||
limit_choices_to = model_field.get_limit_choices_to()
|
|
||||||
if limit_choices_to:
|
|
||||||
kwargs['queryset'] = kwargs['queryset'].filter(**limit_choices_to)
|
|
||||||
|
|
||||||
if model_field.has_default() or model_field.blank or model_field.null:
|
if model_field.has_default() or model_field.blank or model_field.null:
|
||||||
kwargs['required'] = False
|
kwargs['required'] = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user