summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorYogyaChugh <yogyachugh.coder@gmail.com>2025-03-22 18:13:26 +0530
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-03-24 17:05:58 +0100
commit7164f080474ef0213d1d6e625db647c45c36a5fb (patch)
tree3c76acd87cd7573d6931147c4385bff2bcd3436f /django/template
parent0b4f2d8d397dacb555b327435d1c815da59feda5 (diff)
Fixed #36271 -- Raised TemplateSyntaxError when using a relative template path with an unknown origin.
Diffstat (limited to 'django/template')
-rw-r--r--django/template/loader_tags.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index 36703b4782..c3eb66b577 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -257,6 +257,13 @@ def construct_relative_path(
# relative path.
return relative_name
+ if current_template_name is None:
+ # Unknown origin (e.g. Template('...').render(Context({...})).
+ raise TemplateSyntaxError(
+ f"The relative path {relative_name} cannot be evaluated due to "
+ "an unknown template origin."
+ )
+
new_name = posixpath.normpath(
posixpath.join(
posixpath.dirname(current_template_name.lstrip("/")),