Opened 8 years ago

Closed 8 years ago

Last modified 2 months ago

#1292 closed defect (fixed)

[patch] Template loader caching can cause circular imports

Reported by: django@… Owned by: adrian
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The template.loader module caches the enabled template loaders in a module global at the time of import. The resulting dynamic imports can lead to problems with circular imports. For example, a circular import will occur if the app_directories template loader is used together with an application that tries to do anything in its that triggers another import of template.loader.

The attached patch resolves this problem by caching only on the first call to find_template_source.

Attachments (1)

loader_caching_fix_r2158.diff (2.6 KB) - added by django@… 8 years ago.
Fix for template loader

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by django@…

Fix for template loader

comment:1 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [2226]) Fixed #1292 -- Fixed potential circular-import problem in template loader. Thanks, Kieran Holland

comment:2 Changed 2 months ago by anonymous

  • Easy pickings unset
  • UI/UX unset

I am using Django release 1.5 and I have this error... Why?

comment:3 Changed 2 months ago by anonymous

I looked in the .py file and the for loop is still global. Honestly this is annoying.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.