Opened 11 years ago

Closed 11 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: no UI/UX: no


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 11 years ago.

Download all attachments as: .zip

Change History (2)

Changed 11 years ago by andyhd

Attachment: raw-limit-choices.patch added

comment:1 Changed 11 years ago by Karen Tracey

Resolution: fixed
Status: newclosed

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

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