@@ -156,14 +156,16 @@ def get_attribute(self, instance):
156
156
# Standard case, return the object instance.
157
157
return get_attribute (instance , self .source_attrs )
158
158
159
- @property
160
- def choices (self ):
159
+ def get_choices (self , cutoff = None ):
161
160
queryset = self .get_queryset ()
162
161
if queryset is None :
163
162
# Ensure that field.choices returns something sensible
164
163
# even when accessed with a read-only field.
165
164
return {}
166
165
166
+ if cutoff is not None :
167
+ queryset = queryset [:cutoff ]
168
+
167
169
return OrderedDict ([
168
170
(
169
171
six .text_type (self .to_representation (item )),
@@ -172,13 +174,17 @@ def choices(self):
172
174
for item in queryset
173
175
])
174
176
177
+ @property
178
+ def choices (self ):
179
+ return self .get_choices ()
180
+
175
181
@property
176
182
def grouped_choices (self ):
177
183
return self .choices
178
184
179
185
def iter_options (self ):
180
186
return iter_options (
181
- self .grouped_choices ,
187
+ self .get_choices ( cutoff = self . html_cutoff ) ,
182
188
cutoff = self .html_cutoff ,
183
189
cutoff_text = self .html_cutoff_text
184
190
)
@@ -487,17 +493,20 @@ def to_representation(self, iterable):
487
493
for value in iterable
488
494
]
489
495
496
+ def get_choices (self , cutoff = None ):
497
+ return self .child_relation .get_choices (cutoff )
498
+
490
499
@property
491
500
def choices (self ):
492
- return self .child_relation . choices
501
+ return self .get_choices ()
493
502
494
503
@property
495
504
def grouped_choices (self ):
496
505
return self .choices
497
506
498
507
def iter_options (self ):
499
508
return iter_options (
500
- self .grouped_choices ,
509
+ self .get_choices ( cutoff = self . html_cutoff ) ,
501
510
cutoff = self .html_cutoff ,
502
511
cutoff_text = self .html_cutoff_text
503
512
)
0 commit comments