#24111: get_template dirs parameter doesn't work for loading of parent template
---------------------------------+--------------------
Reporter: ThomasWaldmann | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
Given: a directory "templates" with templates "something.txt" and
"base.txt" (and something.txt extends base.txt) and this code:
{{{
def render_template(template, context):
this_dir = os.path.abspath(os.path.dirname(__file__))
template_dir = os.path.join(this_dir, 'templates')
t = loader.get_template(template, dirs=[template_dir, ])
return t.render(Context(context))
# finds and renders base.txt:
render_template("base.txt")
# finds and tries to render something.txt, but then fails to find
base.txt:
render_template("something.txt")
}}}
I wanted to use this for django management commands which send emails, so
I just wanted to load templates from a specific directory.
--
Ticket URL: <https://code.djangoproject.com/ticket/24111>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/057.0716707edb322922fe4afbe8881845b5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.