summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2026-04-26 07:53:13 +0100
committerJacob Walls <jacobtylerwalls@gmail.com>2026-04-28 13:07:11 -0400
commit5d911f2d2fecc703be91b2b9b28acc59d34b35f3 (patch)
treefc32596b2e51593a9da35fda6c3833e70c0e2a56 /django
parente8c6322b4f2ab4df610bb480003a54c88f32210e (diff)
Fixed #35738 -- Deprecated double-dot variable lookups.
Diffstat (limited to 'django')
-rw-r--r--django/template/base.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/django/template/base.py b/django/template/base.py
index 9d75111e42..8c6390de33 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -57,7 +57,7 @@ import warnings
from enum import Enum
from django.template.context import BaseContext
-from django.utils.deprecation import django_file_prefixes
+from django.utils.deprecation import RemovedInDjango70Warning, django_file_prefixes
from django.utils.formats import localize
from django.utils.html import conditional_escape
from django.utils.inspect import lazy_annotations, signature
@@ -555,6 +555,23 @@ class Parser:
except TemplateSyntaxError as e:
raise self.error(token, e)
var_node = VariableNode(filter_expression)
+ if ".." in str(filter_expression.var):
+ warnings.warn(
+ "Support for double-dot lookups '..' which maps to a "
+ "lookup of the empty string is deprecated.\n"
+ f" Template: {self.origin.name}\n"
+ f" Line: {token.lineno}",
+ RemovedInDjango70Warning,
+ skip_file_prefixes=django_file_prefixes(),
+ )
+
+ # RemovedInDjango70Warning
+ # When deprecation ends elevate the warning to an error.
+ # raise self.error(
+ # token,
+ # ("Variable contains '..' on line %d" % token.lineno),
+ # )
+
self.extend_nodelist(nodelist, var_node, token)
elif token_type == 2: # TokenType.BLOCK
try: