Code

Ticket #3096: 3096-filterspecs-newforms-admin.diff

File 3096-filterspecs-newforms-admin.diff, 669 bytes (added by Will Hardy, 7 years ago)

newforms-admin version of patch to take limit_choices_to into account for list_filter in Admin

Line 
1Index: django/contrib/admin/filterspecs.py
2===================================================================
3--- django/contrib/admin/filterspecs.py (revision 6524)
4+++ django/contrib/admin/filterspecs.py (working copy)
5@@ -58,7 +58,7 @@
6             self.lookup_title = f.verbose_name
7         self.lookup_kwarg = '%s__%s__exact' % (f.name, f.rel.to._meta.pk.name)
8         self.lookup_val = request.GET.get(self.lookup_kwarg, None)
9-        self.lookup_choices = f.rel.to._default_manager.all()
10+        self.lookup_choices = f.rel.to._default_manager.complex_filter(f.rel.limit_choices_to)
11 
12     def has_output(self):
13         return len(self.lookup_choices) > 1