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: jamesturk
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:


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):

class BookAdmin(admin.ModelAdmin):
    raw_id_fields = ('author',), AuthorAdmin), 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):

then the select drop down lists the right options.

Attachments (1)

raw_id_limit_choices_admin.diff (1.3 KB) - added by jamesturk 8 years ago.
small patches admin/views/ and admin/ fix this issue

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by jamesturk

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to jamesturk
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Changed 8 years ago by jamesturk

small patches admin/views/ and admin/ fix this issue

comment:2 Changed 8 years ago by jamesturk

  • Has patch set

comment:3 Changed 8 years ago by brosner

  • milestone changed from 1.0 beta to 1.0

comment:4 Changed 8 years ago by msaelices

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

comment:5 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:6 Changed 5 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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