summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorPreston Timmons <prestontimmons@gmail.com>2013-08-30 14:08:40 -0500
committerTim Graham <timograham@gmail.com>2013-09-06 09:14:52 -0400
commit8625c7aab3760d16572792fea23a95e572e28ead (patch)
tree285f010640ccdd7934e0826f169faa694d9985e4 /docs
parente1266e50b29540c07a78ab6f544d9a5073ee8a58 (diff)
Fixed #16096 -- Added origin attribute to template instances.
Thanks jdunck for the suggestion.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/templates/api.txt37
-rw-r--r--docs/releases/1.7.txt4
2 files changed, 40 insertions, 1 deletions
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
index 05f8c249c5..b0fc94040a 100644
--- a/docs/ref/templates/api.txt
+++ b/docs/ref/templates/api.txt
@@ -759,10 +759,45 @@ Django uses the template loaders in order according to the
:setting:`TEMPLATE_LOADERS` setting. It uses each loader until a loader finds a
match.
+.. currentmodule:: django.template
+
+Template origin
+~~~~~~~~~~~~~~~
+
+.. versionadded:: 1.7
+
+When :setting:`TEMPLATE_DEBUG` is ``True`` template objects will have an
+``origin`` attribute depending on the source they are loaded from.
+
+.. class:: loader.LoaderOrigin
+
+ Templates created from a template loader will use the
+ ``django.template.loader.LoaderOrigin`` class.
+
+ .. attribute:: name
+
+ The path to the template as returned by the template loader.
+ For loaders that read from the file system, this is the full
+ path to the template.
+
+ .. attribute:: loadname
+
+ The relative path to the template as passed into the
+ template loader.
+
+.. class:: StringOrigin
+
+ Templates created from a ``Template`` class will use the
+ ``django.template.StringOrigin`` class.
+
+ .. attribute:: source
+
+ The string used to create the template.
+
The ``render_to_string`` shortcut
===================================
-.. function:: django.template.loader.render_to_string(template_name, dictionary=None, context_instance=None)
+.. function:: loader.render_to_string(template_name, dictionary=None, context_instance=None)
To cut down on the repetitive nature of loading and rendering
templates, Django provides a shortcut function which largely
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt
index aa68b722b6..1390317875 100644
--- a/docs/releases/1.7.txt
+++ b/docs/releases/1.7.txt
@@ -272,6 +272,10 @@ Templates
* It is now possible to :ttag:`include` templates recursively.
+* Template objects now have an origin attribute set when
+ :setting:`TEMPLATE_DEBUG` is ``True``. This allows template origins to be
+ inspected and logged outside of the ``django.template`` infrastructure.
+
Backwards incompatible changes in 1.7
=====================================