summaryrefslogtreecommitdiff
path: root/django/template/base.py
diff options
context:
space:
mode:
authorfarhan <farhanalirazaazeemi@gmail.com>2025-09-02 14:59:30 -0400
committerJacob Walls <jacobtylerwalls@gmail.com>2025-09-03 10:59:58 -0400
commit3485599ef08811e2fd066458aa083b2567f3cb84 (patch)
treec3e092941d0fc14e88a5f540f1314ea3633f3602 /django/template/base.py
parentf0c05a40d27d69ef3a7b4e5e0199b5dba5b11feb (diff)
Refs #36559 -- Ran template partial source tests in debug mode only.
Added a warning for accessing PartialTemplate.source when debugging is disabled. Thanks Sarah Boyce for the idea.
Diffstat (limited to 'django/template/base.py')
-rw-r--r--django/template/base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/template/base.py b/django/template/base.py
index 74b3987410..d7bc59d668 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -53,6 +53,7 @@ times with multiple contexts)
import inspect
import logging
import re
+import warnings
from enum import Enum
from django.template.context import BaseContext
@@ -329,6 +330,13 @@ class PartialTemplate:
@property
def source(self):
template = self.origin.loader.get_template(self.origin.template_name)
+ if not template.engine.debug:
+ warnings.warn(
+ "PartialTemplate.source is only available when template "
+ "debugging is enabled.",
+ RuntimeWarning,
+ stacklevel=2,
+ )
return self.find_partial_source(template.source, self.name)
def _render(self, context):