[Django] #34155: ModelAdmin.render_change_form does not lowercase the app_label when setting template directories

3 views
Skip to first unread message

Django

unread,
Nov 14, 2022, 1:01:43 AM11/14/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-----------------------------------------+------------------------
Reporter: RishiDiwanTT | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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
In Linux:
Overwrite `template/django/admin/App/inventory/change_form.html`
In OSX:
Overwrite `template/django/admin/app/inventory/change_form.html`

The app_label variable should be lowercased so the differing file systems
do not cause this issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/34155>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 14, 2022, 1:02:16 AM11/14/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-------------------------------+--------------------------------------

Reporter: RishiDiwanTT | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by RishiDiwanTT):

* version: 4.1 => 3.2


--
Ticket URL: <https://code.djangoproject.com/ticket/34155#comment:1>

Django

unread,
Nov 14, 2022, 1:48:23 AM11/14/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-------------------------------+--------------------------------------
Reporter: Rishi Diwan | Owner: nobody

Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Rishi Diwan:

Old description:

> 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
> In Linux:
> Overwrite `template/django/admin/App/inventory/change_form.html`
> In OSX:
> Overwrite `template/django/admin/app/inventory/change_form.html`
>
> The app_label variable should be lowercased so the differing file systems
> do not cause this issue.

New description:

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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34155#comment:2>

Django

unread,
Nov 14, 2022, 1:49:22 AM11/14/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-------------------------------+--------------------------------------
Reporter: Rishi Diwan | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Rishi Diwan):

* easy: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34155#comment:3>

Django

unread,
Nov 14, 2022, 1:50:32 AM11/14/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-------------------------------+--------------------------------------
Reporter: Rishi Diwan | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 3.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Rishi Diwan):

* component: Uncategorized => contrib.admin


--
Ticket URL: <https://code.djangoproject.com/ticket/34155#comment:4>

Django

unread,
Nov 14, 2022, 5:57:42 AM11/14/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-------------------------------+--------------------------------------
Reporter: Rishi Diwan | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* cc: Carlton Gibson (added)
* status: new => closed
* resolution: => needsinfo
* easy: 1 => 0


Comment:

> The `app_label` variable should be lowercased so the differing file
systems do not cause this issue.

`app` and `App` are two different directories, so forcing lowercase would
be highly backward incompatible. As far as I'm aware, the `APFS`
filesystem is not case insensitive so I'm sure what kind of issue you are
facing 🤔

--
Ticket URL: <https://code.djangoproject.com/ticket/34155#comment:5>

Django

unread,
Nov 15, 2022, 5:10:08 AM11/15/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-------------------------------+--------------------------------------
Reporter: Rishi Diwan | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Carlton Gibson):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34155#comment:6>

Django

unread,
Nov 15, 2022, 5:17:18 AM11/15/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-------------------------------+--------------------------------------
Reporter: Rishi Diwan | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Mariusz Felisiak):

> macOS APFS is case insensitive:

TIL

--
Ticket URL: <https://code.djangoproject.com/ticket/34155#comment:7>

Django

unread,
Nov 16, 2022, 1:29:06 AM11/16/22
to django-...@googlegroups.com
#34155: ModelAdmin.render_change_form does not lowercase the app_label when setting
template directories
-------------------------------+--------------------------------------
Reporter: Rishi Diwan | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Rishi Diwan):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/34155#comment:8>

Reply all
Reply to author
Forward
0 new messages