Opened 7 years ago

Closed 7 years ago

#9561 closed (fixed)

ForeignKeyRawIdWidget turns string into comma-separated chars in lookup URL

Reported by: andyhd Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords: ForeignKeyRawIdWidget limit_choices_to
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Using a ForeignKey with limit_choices_to a filter that matches a string:

class Foo(models.Model):
    bar = models.ForeignKey('Bar', limit_choices_to={'blarch': 'quux'})
#                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
class Bar(models.Model):
    blarch = models.CharField(max_length=20)

And a custom admin with raw_id_fields:

class FooAdmin(admin.ModelAdmin):
    raw_id_fields = ('bar',)

results in the changeform magnifying glass lookup link having a URL like this:

Fixed by placing the single string value in a list (see patch)

Attachments (1)

raw-limit-choices.patch (559 bytes) - added by andyhd 7 years ago.

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by andyhd

comment:1 Changed 7 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

Looks like James fixed this with a slightly different patch in r9533/r9534.

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