From 37f25d4c0cde5afa0e8178b424b5b80eff44de02 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 24 Mar 2009 07:05:57 +0000 Subject: [PATCH] Fixed #9994 -- Fixed admin filtering when to_field is used on relations. Thanks to jzylks for diagnosing this one. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10139 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/filterspecs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django/contrib/admin/filterspecs.py b/django/contrib/admin/filterspecs.py index 97f4cb2056..fd258df6b7 100644 --- a/django/contrib/admin/filterspecs.py +++ b/django/contrib/admin/filterspecs.py @@ -58,7 +58,8 @@ class RelatedFilterSpec(FilterSpec): self.lookup_title = f.rel.to._meta.verbose_name else: self.lookup_title = f.verbose_name - self.lookup_kwarg = '%s__%s__exact' % (f.name, f.rel.to._meta.pk.name) + rel_name = f.rel.get_related_field().name + self.lookup_kwarg = '%s__%s__exact' % (f.name, rel_name) self.lookup_val = request.GET.get(self.lookup_kwarg, None) self.lookup_choices = f.get_choices(include_blank=False)