Skip to content

Commit e065874

Browse files
author
Konstantinos Bairaktaris
committed
Fix outstanding issues with Django-4
- Version comparison - Issue with FilterExpressions
1 parent de0380a commit e065874

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

transifex/native/django/templatetags/transifex.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,24 @@ def render(self, context):
259259
# it back in place before returning from render.
260260
# https://docs.djangoproject.com/en/1.11/howto/custom-template-tags/#thread-safety-considerations # noqa
261261
old_source_string_var = self.source_string.var
262+
try:
263+
old_is_var = self.source_string.is_var
264+
except AttributeError:
265+
old_is_var = None
262266

263267
# Now we resolve the full source filter expression, after having
264268
# replaced its text with the outcome of the translation, in order to
265269
# apply the expression's filters to the translation. The translation is
266270
# marked as safe in order to prevent further escaping attempts that
267271
# would introduce the danger of double escaping (eg `<` => `&amp;lt;`)
268272
self.source_string.var = mark_safe(result)
273+
self.source_string.is_var = False
274+
269275
result = self.source_string.resolve(context)
276+
270277
self.source_string.var = old_source_string_var
278+
if old_is_var is not None:
279+
self.source_string.is_var = old_is_var
271280

272281
if self.asvar is not None:
273282
# Save the translation outcome to a context variable

transifex/native/django/tools/migrations/templatetags.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def _get_ordered_tokens(parser):
5858
This method is useful when we want to iterate all the remaining
5959
tokens of the parser in the correct order.
6060
"""
61-
if DJANGO_VERSION[0] >= 3 and DJANGO_VERSION[1] > 1:
61+
major, minor = DJANGO_VERSION[:2]
62+
if major == 3 and minor > 1 or major > 3:
6263
return reversed(parser.tokens)
6364
return parser.tokens
6465

0 commit comments

Comments
 (0)