Opened 8 years ago

Closed 8 years ago

Last modified 5 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: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 8 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 Changed 8 years ago by James Turk

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

Changed 8 years ago by James Turk

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

comment:2 Changed 8 years ago by James Turk

Has patch: set

comment:3 Changed 8 years ago by Brian Rosner

milestone: 1.0 beta1.0

comment:4 Changed 8 years ago by Manuel Saelices

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

comment:5 Changed 8 years ago by Jacob

Resolution: fixed
Status: assignedclosed

comment:6 Changed 5 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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