#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):
https://i.ibb.co/whYXg2Q/Administration.png

The strange thing is that I can't reproduce this behaviour in my local version.

Change History (2)

comment:1 Changed 14 months ago by Mathis

Type: UncategorizedBug

comment:2 Changed 14 months ago by Mariusz Felisiak

Resolution: duplicate
Status: newclosed
Summary: Admin panel: edit popup in model 'change' page results in a not found if the foreign key model contains a spaceEdit 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.

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