Skip to content

Commit 7b5c194

Browse files
committed
Fix django-commons#2109: Recursively unwrap loaders to support template partials
1 parent 9ec1578 commit 7b5c194

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

debug_toolbar/panels/templates/views.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ def template_source(request):
2727
template_name = request.GET.get("template", template_origin_name)
2828

2929
final_loaders = []
30-
loaders = Engine.get_default().template_loaders
30+
loaders = list(Engine.get_default().template_loaders)
31+
32+
while loaders:
33+
loader = loaders.pop(0)
3134

32-
for loader in loaders:
3335
if loader is not None:
34-
# When the loader has loaders associated with it,
35-
# append those loaders to the list. This occurs with
36-
# django.template.loaders.cached.Loader
36+
# Recursively unwrap loaders until we get to loaders which do not
37+
# themselves wrap other loaders. This occurs
38+
# with django.template.loaders.cached.Loader and the
39+
# django-template-partials loader (possibly among others)
3740
if hasattr(loader, "loaders"):
38-
final_loaders += loader.loaders
41+
loaders.extend(loader.loaders)
3942
else:
4043
final_loaders.append(loader)
4144

0 commit comments

Comments
 (0)