Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…ignKey.to_field. Thanks for reporting,

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 97e820ab3a71c65a39d8ce2539735dc9c73b5cec 1 parent 1a428ec
@adrianholovaty adrianholovaty authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  django/db/models/fields/
2  django/db/models/fields/
@@ -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 =
- 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):
Please sign in to comment.
Something went wrong with that request. Please try again.