Skip to content

Fixed #16096 - Add origin attribute to template instances. #1534

Closed
wants to merge 1 commit into from

2 participants

@prestontimmons

Adding a pull request for this ticket:

https://code.djangoproject.com/ticket/16096

@timgraham timgraham and 1 other commented on an outdated diff Sep 5, 2013
django/template/base.py
@@ -120,10 +120,11 @@ def __init__(self, template_string, origin=None,
except UnicodeDecodeError:
raise TemplateEncodingError("Templates can only be constructed "
"from unicode or UTF-8 strings.")
- if settings.TEMPLATE_DEBUG and origin is None:
@timgraham
Django member
timgraham added a note Sep 5, 2013

I'm wary of removing the settings.TEMPLATE_DEBUG check without some justification. Could you explain your thinking?

Part of the use-case in the ticket was the ability to log template origins outside of the django.template infrastructure, which could even apply to production. But changing this could introduce some unknowns.

I'll undo that change and update the branch. I'll also update the docs.

Thanks for reviewing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham timgraham commented on an outdated diff Sep 5, 2013
docs/ref/templates/api.txt
@@ -759,6 +759,29 @@ Django uses the template loaders in order according to the
:setting:`TEMPLATE_LOADERS` setting. It uses each loader until a loader finds a
match.
+Template origin
+~~~~~~~~~~~~~~~
+
+Templates have an ``origin`` attribute that depends on the source they are
+loaded from.
+
+LoaderOrigin
@timgraham
Django member
timgraham added a note Sep 5, 2013

Could we document this using the standard .. class and ..attribute markers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham timgraham commented on the diff Sep 5, 2013
docs/ref/templates/api.txt
@@ -759,6 +759,29 @@ Django uses the template loaders in order according to the
:setting:`TEMPLATE_LOADERS` setting. It uses each loader until a loader finds a
match.
+Template origin
@timgraham
Django member
timgraham added a note Sep 5, 2013

needs ..versionadded:: 1.7 and should also be mentioned in the release notes

The PR is updated with a simplified patch and updated docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham
Django member

merged in 8625c7a - thanks!

@timgraham timgraham closed this Sep 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.