Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #2463 -- Fixed temporarily broken many-to-many fields in admin …

…interface due to [3507]. Thanks, Nesh

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3508 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ad39bb1620a962597e8ed6c6d956e01a33fc654a 1 parent 97e820a
@adrianholovaty adrianholovaty authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 django/db/models/fields/__init__.py
View
7 django/db/models/fields/__init__.py
@@ -289,8 +289,11 @@ def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH):
if self.choices:
return first_choice + list(self.choices)
rel_model = self.rel.to
- return first_choice + [(getattr(x, self.rel.get_related_field().attname), str(x))
- for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)]
+ if hasattr(self.rel, 'get_related_field'):
+ 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)]
+ else:
+ lst = [(x._get_pk_val(), str(x)) for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)]
+ return first_choice + lst
def get_choices_default(self):
if self.radio_admin:
Please sign in to comment.
Something went wrong with that request. Please try again.