#14880: raw_id_fields in admin does not work when limit_choices_to dictionary 
has
value=False
----------------------------------+-----------------------------------------
 Reporter:  [email protected]   |       Owner:  nobody    
   Status:  new                   |   Milestone:            
Component:  django.contrib.admin  |     Version:  1.2       
 Keywords:                        |       Stage:  Unreviewed
Has_patch:  0                     |  
----------------------------------+-----------------------------------------
 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)
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14880>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to