Ticket #3436: 3436.diff
File 3436.diff, 1.4 KB (added by , 18 years ago) |
---|
-
django/db/models/fields/__init__.py
287 287 288 288 def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH): 289 289 "Returns a list of tuples used as SelectField choices for this field." 290 first_choice = include_blank and blank_choice or [] 290 if include_blank: 291 yield blank_choice[0] 291 292 if self.choices: 292 return first_choice + list(self.choices) 293 for choice in self.choices: 294 yield choice 295 return 293 296 rel_model = self.rel.to 294 if hasattr(self.rel, 'get_related_field'):295 lst = [(getattr(x, self.rel.get_related_field().attname), str(x)) for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)]296 else:297 lst = [(x._get_pk_val(), str(x)) for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)]298 return first_choice + lst297 for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to): 298 if hasattr(self.rel, 'get_related_field'): 299 yield (getattr(x, self.rel.get_related_field().attname), str(x)) 300 else: 301 yield (x._get_pk_val(), str(x)) 299 302 300 303 def get_choices_default(self): 301 304 if self.radio_admin: