mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-09 23:04:47 +03:00
Limit querysets to html_cutoff when rendering relational choices
This commit is contained in:
parent
54b5f05676
commit
27fc3cd4bd
|
@ -163,7 +163,7 @@ class RelatedField(Field):
|
|||
# even when accessed with a read-only field.
|
||||
return {}
|
||||
|
||||
if cutoff:
|
||||
if cutoff is not None:
|
||||
queryset = queryset[:cutoff]
|
||||
|
||||
return OrderedDict([
|
||||
|
@ -184,7 +184,7 @@ class RelatedField(Field):
|
|||
|
||||
def iter_options(self):
|
||||
return iter_options(
|
||||
self.get_choices(self.html_cutoff),
|
||||
self.get_choices(cutoff=self.html_cutoff),
|
||||
cutoff=self.html_cutoff,
|
||||
cutoff_text=self.html_cutoff_text
|
||||
)
|
||||
|
@ -493,9 +493,12 @@ class ManyRelatedField(Field):
|
|||
for value in iterable
|
||||
]
|
||||
|
||||
def get_choices(self, cutoff=None):
|
||||
return self.child_relation.get_choices(cutoff)
|
||||
|
||||
@property
|
||||
def choices(self):
|
||||
return self.child_relation.choices
|
||||
return self.get_choices()
|
||||
|
||||
@property
|
||||
def grouped_choices(self):
|
||||
|
@ -503,7 +506,7 @@ class ManyRelatedField(Field):
|
|||
|
||||
def iter_options(self):
|
||||
return iter_options(
|
||||
self.grouped_choices,
|
||||
self.get_choices(cutoff=self.html_cutoff),
|
||||
cutoff=self.html_cutoff,
|
||||
cutoff_text=self.html_cutoff_text
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user