Skip to content

Commit edf593c

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

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+
from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
4+
except ImportError:
5+
# Django 2.1+
6+
from django.template.base import Lexer, TokenType
7+
8+
TOKEN_TEXT = TokenType.TEXT
9+
TOKEN_VAR = TokenType.VAR
10+
TOKEN_BLOCK = TokenType.BLOCK
11+
312
from django.utils.translation import trim_whitespace
413
from django.utils.encoding import smart_text
514

0 commit comments

Comments
 (0)