Re: [Django] #36028: Add option to choose a specific template engine for Django Admin

3 views
Skip to first unread message

Django

unread,
Dec 20, 2024, 3:37:00 AM12/20/24
to django-...@googlegroups.com
#36028: Add option to choose a specific template engine for Django Admin
------------------------------------+--------------------------------------
Reporter: Foucauld Degeorges | Owner: (none)
Type: New feature | Status: new
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: template engine | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Foucauld Degeorges):

* has_patch: 0 => 1


Old description:

> Context:
> We have two template engines in our app - one that is permissive with
> invalid variables (e.g. accessing a property on None), the other one
> raises on invalid variables.
> Django Admin requires the permissive one as it makes use of the fallback
> mechanic on invalid variables.
>
> But we prefer for all our other renders (views, emails, PDFs) to be
> strict on invalid variables. So we want our strict template engine to be
> the default one, and specify a custom one for the admin.
>
> The idea would be a Django admin setting named something like
> {{{ADMIN_TEMPLATE_ENGINE_NAME}}}, that sets the {{{using}}} argument of
> all {{{TemplateResponses}}} returned by admin views.

New description:

Context:
We have two template engines in our app - one that is permissive with
invalid variables (e.g. accessing a property on None), the other one
raises on invalid variables.
Django Admin requires the permissive one as it makes use of the fallback
mechanic on invalid variables.

But we prefer for all our other renders (views, emails, PDFs) to be strict
on invalid variables. So we want our strict template engine to be the
default one, and specify a custom one for the admin.

The idea would be an optional property on {{{AdminSite}}} named
{{{template_engine}}}, that sets the {{{using}}} argument of all
{{{TemplateResponses}}} returned by admin views.

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

Django

unread,
Dec 20, 2024, 7:47:15 AM12/20/24
to django-...@googlegroups.com
#36028: Add option to choose a specific template engine for Django Admin
------------------------------------+--------------------------------------
Reporter: Foucauld Degeorges | Owner: (none)
Type: New feature | Status: closed
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution: wontfix
Keywords: template engine | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Natalia Bidart):

* cc: Adam Johnson (added)
* resolution: => wontfix
* status: new => closed

Comment:

Hello Foucauld Degeorges! Thank you for your report and interest in making
Django better.

The new feature that you are proposing seems a very specific need arising
from a niche use case. I don't think this applies to the broader
ecosystem, and Django is a framework designed to offer robust and accurate
solutions for **common** scenarios.

There are posts from, for example, Adam Johnson about being verbose and
selective about missing variables in templates, without resorting to
multiple engines. See for example:

https://adamj.eu/tech/2022/03/30/how-to-make-django-error-for-undefined-
template-variables/
https://adamj.eu/tech/2023/08/09/django-perils-string-if-invalid/

Given the above, I'll close the ticket accordingly, but if you disagree,
you can consider starting a new conversation on the
[https://forum.djangoproject.com/c/internals/5 Django Forum], where you'll
reach a wider audience and likely get extra feedback. More information in
[https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
features/#requesting-features the documented guidelines for requesting
features].
--
Ticket URL: <https://code.djangoproject.com/ticket/36028#comment:4>
Reply all
Reply to author
Forward
0 new messages