Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def parse(self, parse_until=None):
except TemplateSyntaxError as e:
raise self.error(token, e)
var_node = VariableNode(filter_expression)
if ".." in str(filter_expression.var):
if filter_expression.is_var and ".." in filter_expression.var.var:
warnings.warn(
"Support for double-dot lookups '..' which maps to a "
"lookup of the empty string is deprecated.\n"
Expand Down
4 changes: 3 additions & 1 deletion docs/releases/6.1.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ Django 6.1.1 fixes several bugs in 6.1.
Bugfixes
========

* ...
* Fixed a regression in Django 6.1 where the deprecation of double-dot variable
lookups incorrectly applied to string and translated template literals
containing two consecutive dots, such as ``{{ "a..b" }}`` (:ticket:`37257`).
14 changes: 14 additions & 0 deletions tests/template_tests/syntax_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,20 @@ def test_double_dot_lookup(self):
# ):
# self.engine.render_to_string("template")

def test_double_dot_in_literal(self):
tests = [
('{{ "hello..world" }}', "hello..world"),
("{{ 'a..b'|upper }}", "A..B"),
('{{ missing|default:"a..b" }}', "a..b"),
('{{ _("a..b") }}', "a..b"),
]
engine = Engine()
for template_string, expected in tests:
with self.subTest(template_string=template_string):
template = engine.from_string(template_string)
output = template.render(Context({}))
self.assertEqual(output, expected)


class BlockContextTests(SimpleTestCase):
def test_repr(self):
Expand Down
Loading