Skip to content

Commit bf11bef

Browse files
committed
Fix imports of token types for Django 2.1
1 parent f2ddaba commit bf11bef

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

django_babel/extract.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# -*- coding: utf-8 -*-
2-
from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
2+
try:
3+
# Django >= 2.1
4+
from django.template.base import Lexer, TokenType
5+
TOKEN_TEXT = TokenType.TEXT
6+
TOKEN_VAR = TokenType.VAR
7+
TOKEN_BLOCK = TokenType.BLOCK
8+
except ImportError:
9+
# Django < 2.1
10+
from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
11+
312
from django.utils.translation import trim_whitespace
413
from django.utils.encoding import smart_text
514

0 commit comments

Comments
 (0)