Opened 3 years ago
Closed 3 years ago
#33051 closed Bug (fixed)
Model names with special characters don't highlight in admin site
Reported by: | ꯸ ꬰ ꝛ⼻ↇ | Owned by: | Hasan Ramezani |
---|---|---|---|
Component: | contrib.admin | Version: | 3.2 |
Severity: | Normal | Keywords: | accents, unicode |
Cc: | Tom Carrick, Matthias Kestenholz | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Create two models, one without special characters Hello
and another with Héllo
, register both with the admin website.
Then, when you click on Hello in the admin website it highlights in yellow in the sidebar, but it is not the case for Héllo, which remains white/gray. This is true for any number of models in any order, only those with an accent will exhibit this behaviour.
Change History (6)
comment:1 by , 3 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 3 years ago
I have never used model names with umlauts or accents; I knew that Python 3 supports using unicode codepoints in class names too but I've never had a reason for using anything but [A-Za-z0-9_]
when naming Django model classes (or any Python identifiers, for that matter)
I don't know that area of the Django admin very well but the fix looks correct to me. At least if Django even wants to support umlauts/accents in model names (and therefore also database table names, maybe?) at all.
request.path
only exists in the admin/app_list.html
template in django/contrib/admin/templates/
so I'd assume that the proposed patch fixes this problem.
TLDR: LGTM but I wouldn't ever use accents or umlauts in class names.
comment:5 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Thanks for the report! Adding
urlencode
fixes this issue for me: