Opened 17 years ago
Closed 17 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 |
Description
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:
"../../../fail/blarch/?blarch=q,u,u,x"
Fixed by placing the single string value in a list (see patch)
Attachments (1)
Change History (2)
by , 17 years ago
| Attachment: | raw-limit-choices.patch added |
|---|
comment:1 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Looks like James fixed this with a slightly different patch in r9533/r9534.