﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3096	Filtering choices in admin list view don't respond to limit_choices_to parameter	Archatas (aidas.bendoraitis at gmail.com)	nobody	"Administration list view shows choices in filters not responding to the limit_choices_to field for the field.

For example, if we have

class Color(models.Model):
    value=models.CharField(...)
    warm=models.BooleanField(...)

class Thing(models.Model):
    title=models.CharField(...)
    color=models.ForeignKey(Color, limit_choices_to={'warm': True})
    class Admin:
        list_filter = ('color',)

We will get all the choices of Color objects listed in the Filter/By Color section instead of getting only those, which are warm.

To fix this, the line
{{{
self.lookup_choices = f.rel.to._default_manager.all()
}}}
at class RelatedFilterSpec(FilterSpec) in the file django/contrib/admin/filterspecs.py has to be changed to
{{{
if f.rel.limit_choices_to:
    self.lookup_choices = f.rel.to._default_manager.filter(**f.rel.limit_choices_to)
else:
    self.lookup_choices = f.rel.to._default_manager.all()
}}}"	defect	new	contrib.admin	SVN	normal				Unreviewed	0	0	0	0	0	0
