Opened 4 years ago
Closed 4 years ago
#32225 closed Bug (duplicate)
Edit popup in model 'change' page results in a not found if the foreign key model contains a space
Reported by: | Mathis | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 3.1 |
Severity: | Normal | Keywords: | admin, edit |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In the 'change' page of the admin panel, if we try to edit a model linked by ForeignKey which contains a space in the 'to_field' property, the result is a 'not found page'.
Example:
class Media(models.Model): author = models.ForeignKey('Author', verbose_name="Author", on_delete=models.SET_NULL, to_field="name", default="Unknown", null=True)
In this case, if the Author.name contains a space, the generated URL to edit this author will be: https://domain.com/admin/web_app/author/Spaced%20Name/change/?_to_field=name&_popup=1
The result is (in french with a translation, sorry):
The strange thing is that I can't reproduce this behaviour in my local version.
Change History (2)
comment:1 by , 4 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 4 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Summary: | Admin panel: edit popup in model 'change' page results in a not found if the foreign key model contains a space → Edit popup in model 'change' page results in a not found if the foreign key model contains a space |
I also cannot reproduce this issue with spaces, but it's possible with other keys, e.g.
_40
. I believe we can close this as a duplicate of #30386, which is due to the fact that foreign key widgets don't quote keys.