#33839: Support pathlib.Path in loaders' get_template().
---------------------------------+-----------------------------------------
Reporter: simon klemenc | Owner: simon klemenc
Type: New feature | Status: assigned
Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+-----------------------------------------
Comment (by David Smith):
I am not sure we need to support `pathlib.Path`?
In the first example there is:
{{{
os.path.join('adminsortable2', app_label, opts.model_name,
'change_list.html'),
}}}
`os.path.join` returns a `str`. If it wanted to be remove the use of `os`
I think string concatenation using f-string or %-format would also work?
e.g.
{{{
f'adminsortable2/{app_label}/{opts.model_name}/change_list.html'
}}}
Assuming, my above statement is correct. Is there a concrete example where
using `pathlib.Path` over string concatenation is preferable?
I'm also thinking about Jinja2 given the original PR targeted that
backend. It's docs say that the template name should be a `str` or
`Template`. I'm not sure it's Django's responsibility to enhance that API
to do conversion of Paths?
https://jinja.palletsprojects.com/en/3.1.x/api/#jinja2.Environment.get_template.
--
Ticket URL: <https://code.djangoproject.com/ticket/33839#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070181f3b955de-422c95d8-14b6-41cb-93cf-8612f42379a9-000000%40eu-central-1.amazonses.com.