Browse files

Fixed #2269 -- limit_choices_to now works properly with a custom Fore…

…ignKey.to_field. Thanks for reporting, mir@noris.de

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3507 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 1a428ec commit 97e820ab3a71c65a39d8ce2539735dc9c73b5cec @adrianholovaty adrianholovaty committed Aug 1, 2006
Showing with 1 addition and 1 deletion.
  1. +1 −1 django/db/models/fields/__init__.py
View
2 django/db/models/fields/__init__.py
@@ -289,7 +289,7 @@ 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 + [(x._get_pk_val(), str(x))
+ 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)]
def get_choices_default(self):

0 comments on commit 97e820a

Please sign in to comment.