mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 01:49:50 +03:00
Fix issue1811: take limit_choices_to into account with FK
This commit is contained in:
parent
63e6bbfd36
commit
2d48dd4e4c
|
@ -169,6 +169,12 @@ class RelatedField(Field):
|
|||
# for the field.
|
||||
# Eg: 'MyRelationship(queryset=ExampleModel.objects.all())'
|
||||
queryset = queryset.all()
|
||||
if hasattr(self.parent, "Meta") and hasattr(self.parent.Meta, "model"):
|
||||
queryset = queryset.filter(
|
||||
**self.parent.Meta.model._meta.get_field(
|
||||
self.source
|
||||
).get_limit_choices_to()
|
||||
)
|
||||
return queryset
|
||||
|
||||
def use_pk_only_optimization(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user