Skip to content

Commit fc612ce

Browse files
committed
Merge pull request python-babel#45 from tsouvarev/django-2.1-compatibility
Django 2.1 compatibility
2 parents f2ddaba + a935848 commit fc612ce

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
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

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{35,36}-djangomaster, py{27,34,35,36}-django{18,111,20}, lint, docs
2+
envlist = py{35,36,37}-django{21,master}, py{27,34,35,36}-django{18,111,20}, lint, docs
33

44
[testenv]
55
deps =
@@ -11,6 +11,7 @@ deps =
1111
django18: Django>=1.8,<1.9
1212
django111: Django>=1.11,<2.0
1313
django20: Django>=2.0,<2.1
14+
django21: Django>=2.1,<2.2
1415
djangomaster: https://github.com/django/django/archive/master.tar.gz#egg=Django
1516
commands = py.test {posargs}
1617

0 commit comments

Comments
 (0)