Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7881 closed (fixed)

raw_id_fields and limit_choices_to with an __in query results in no output in popup list

Reported by: Matthew Flanagan <mattimustang@…> Owned by: James Turk
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Here is a contrived example:

class Author(models.Model):
    name = models.CharField(max_length=64)

class Book(models.Model):
    name = models.Charfield(max_length=64)
    author = models.ForeignKey(Author, limit_choices_to = {'name__in': ('Oscar','Hugo')})

class AuthorAdmin(admin.ModelAdmin):
    pass

class BookAdmin(admin.ModelAdmin):
    raw_id_fields = ('author',)

admin.site.register(Author, AuthorAdmin)
admin.site.register(Book, BookAdmin)
>>> from models import Author
>>> Author.objects.create(name='Oscar')
>>> Author.objects.create(name='Matthew')
>>> Author.objects.create(name='Hugo')

Now in the Admin when editing a Book if I click on the magnifying glass to select an Author then the list in the popup is empty. If I change BookAdmin to be:

class BookAdmin(admin.ModelAdmin):
    pass

then the select drop down lists the right options.

Attachments (1)

raw_id_limit_choices_admin.diff (1.3 KB ) - added by James Turk 16 years ago.
small patches admin/views/main.py and admin/widgets.py fix this issue

Download all attachments as: .zip

Change History (7)

comment:1 by James Turk, 16 years ago

Owner: changed from nobody to James Turk
Status: newassigned
Triage Stage: UnreviewedAccepted

by James Turk, 16 years ago

small patches admin/views/main.py and admin/widgets.py fix this issue

comment:2 by James Turk, 16 years ago

Has patch: set

comment:3 by Brian Rosner, 16 years ago

milestone: 1.0 beta1.0

comment:4 by Manuel Saelices, 16 years ago

@jacob, is this ticket fixed in [8700] ??

comment:5 by Jacob, 16 years ago

Resolution: fixed
Status: assignedclosed

comment:6 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top