﻿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
14880	raw_id_fields in admin does not work when limit_choices_to dictionary has value=False	smallming@…	Luke Plant	"The related-lookup popup does not properly filter the queryset when the limit_choices_to dictionary has value=False. The models.py and admin.py demonstrate the problem.

[[BR]]

To reproduce:

1. Using the following models.py and admin.py, do 
{{{
Publisher(name='local', overseas=False).save()
Publisher(name='overseas', overseas=True).save()
}}}
2. Inside admin interface > add book, select related-lookup link to display popup. Only publisher ""overseas"" is available. Should display publisher ""local"" only.

[[BR]]

Work-around: setting limit_choices_to={'overseas': 0} works, but this work-around is less intuitive than a fix.

[[BR]]

models.py

{{{
from django.db import models

class Publisher(models.Model):
    name        = models.CharField(max_length=20)
    overseas    = models.BooleanField()

class Book(models.Model):
    title           = models.CharField(max_length=20)
    local_publisher = models.ForeignKey(Publisher, limit_choices_to={'overseas': False})

}}}

admin.py

{{{
from testproj.testapp.models import *
from django.contrib import admin

class BookAdmin(admin.ModelAdmin):
    raw_id_fields = ['local_publisher',]

class PublisherAdmin(admin.ModelAdmin):
    list_display = ['name', 'overseas']

admin.site.register(Book, BookAdmin)
admin.site.register(Publisher, PublisherAdmin)
}}}

"		closed	contrib.admin	1.2		fixed			Accepted	0	0	0	0	0	0
