Ticket #3096: 3096-filterspecs.patch

File 3096-filterspecs.patch, 786 bytes (added by Robert Myers <myer0052@…>, 18 years ago)

filterspecs limit_choices_to patch

  • django/contrib/admin/filterspecs.py

     
    5656            self.lookup_title = f.verbose_name
    5757        self.lookup_kwarg = '%s__%s__exact' % (f.name, f.rel.to._meta.pk.name)
    5858        self.lookup_val = request.GET.get(self.lookup_kwarg, None)
    59         self.lookup_choices = f.rel.to._default_manager.all()
     59        if f.rel.limit_choices_to:
     60            self.lookup_choices = f.rel.to._default_manager.filter(**f.rel.limit_choices_to)
     61        else:
     62            self.lookup_choices = f.rel.to._default_manager.all()
    6063
    6164    def has_output(self):
    6265        return len(self.lookup_choices) > 1
Back to Top