Opened 7 years ago

Last modified 7 years ago

#28825 closed Uncategorized

Templated email with {% extends parent_name %} doesn't re-resolve the base template — at Initial Version

Reported by: Andrew Owned by: nobody
Component: Template system Version: 1.11
Severity: Normal Keywords:
Cc: awbacker@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django templating you can use {% extends parent_name %} to indicate that the template is derived from another. We use this feature along with django-templated-email to have different base email templates for white-label purposes.

The issue appears to be that {% extends parent_name %} does not get re-evaluated when the variable changes, eg. from email/app1.email to email/app2.email.

  • The Engine uses django.template.loaders.cached.Loader
  • The first time the template is loaded, the parent template is loaded based on parent_name is loaded
  • Subsequent emails load the template, but do not re-evaluate the extends

If this is as-designed, how would one go about clearing out that cache. I am using code like this (when setting up my test case) but it doesn't appear to clear the cache, even though my print() debugging shows its the same object (<django.template.loaders.cached.Loader object at 0x113e99828>_

for template in engines.all():
        for loader in template.engine.template_loaders:
            loader.reset()

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top