Code

Ticket #17199: #17199-template_loader_origin.diff

File #17199-template_loader_origin.diff, 1.5 KB (added by Kronuz, 2 years ago)
Line 
1Index: /usr/local/www/django/template/loader.py
2===================================================================
3--- django/template/loader.py
4+++ django/template/loader.py   (working copy)
5@@ -46,7 +46,7 @@
6         origin = make_origin(display_name, self.load_template_source, template_name, template_dirs)
7         try:
8             template = get_template_from_string(source, origin, template_name)
9-            return template, None
10+            return template, origin and origin.name
11         except TemplateDoesNotExist:
12             # If compiling the template we found raises TemplateDoesNotExist, back off to
13             # returning the source and display name for the template we were asked to load.
14Index: /usr/local/www/django/template/loaders/cached.py
15===================================================================
16--- django/template/loaders/cached.py
17+++ django/template/loaders/cached.py   (working copy)
18@@ -50,9 +50,9 @@
19                     # back off to returning the source and display name for the template
20                     # we were asked to load. This allows for correct identification (later)
21                     # of the actual template that does not exist.
22-                    return template, origin
23-            self.template_cache[key] = template
24-        return self.template_cache[key], None
25+                    return template, origin and origin.name
26+            self.template_cache[key] = (template, origin and origin.name)
27+        return self.template_cache[key]
28 
29     def reset(self):
30         "Empty the template cache."