#34155 closed Uncategorized (needsinfo)
ModelAdmin.render_change_form does not lowercase the app_label when setting template directories
| Reported by: | Rishi Diwan | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | 3.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Carlton Gibson | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
In case of differing environments, such as the linux FS and the OSX FS, folders case-matching is important.
Consider an application with:
app label = "App"
model name = "Inventory" with tablename="inventory"
If a particular model's change_form.html needs to be overwritten we would do the following
Overwrite template/django/admin/App/inventory/change_form.html
This works fine on Linux systems.
However on OSX systems the file shows up as template/django/admin/app/inventory/change_form.html.
This breaks the functionality since the template is no longer found in the App/inventory directory.
The app_label variable should be lowercased so the differing file systems do not cause this issue.
Change History (8)
comment:1 by , 3 years ago
| Version: | 4.1 → 3.2 |
|---|
comment:2 by , 3 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 3 years ago
| Easy pickings: | set |
|---|
comment:4 by , 3 years ago
| Component: | Uncategorized → contrib.admin |
|---|
comment:5 by , 3 years ago
| Cc: | added |
|---|---|
| Easy pickings: | unset |
| Resolution: | → needsinfo |
| Status: | new → closed |
follow-up: 7 comment:6 by , 3 years ago
macOS APFS is case insensitive:
% mkdir App % mkdir app mkdir: app: File exists % ls App % diskutil info /System/Volumes/Data | grep Personality File System Personality: APFS
However...
However on OSX systems the file shows up as template/django/admin/app/inventory/change_form.html.
This breaks the functionality since the template is no longer found in the App/inventory directory.
On macOS I'd expect the template to be found regardless of the casing of the app directory.
(A full runnable example showing otherwise please.)
This is a long-standing gotcha of macOS. Linux has case sensitive names so don't use App unless you mean it there. It's best just to use lowercase, and then you don't hit problems.
(Use AppConfig.verbose_name if you want that for display purposes.)
...forcing lowercase would be highly backward incompatible
Exactly. This isn't something we can realistically change.
comment:8 by , 3 years ago
I agree backward compatibility breaks, but there is a consistency issue here.
InculsionAdminNode.render explicitly does a app_label.lower() so we now have two folders with different cases for the different admin templates.
The case-sensitive folder has issues in the OSX folders because of the FS.
appandAppare two different directories, so forcing lowercase would be highly backward incompatible. As far as I'm aware, theAPFSfilesystem is not case insensitive so I'm sure what kind of issue you are facing 🤔