Remove Django<1.8 compatibility safeguards

This commit is contained in:
Aarni Koskela 2016-09-06 18:48:50 +03:00
parent 88b389381c
commit 30a59664d6
2 changed files with 3 additions and 26 deletions

View File

@ -1,31 +1,11 @@
# -*- coding: utf-8 -*-
try:
from django.template import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
except ImportError:
# Django 1.8 moved most stuff to .base
from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
try:
from django.utils.translation import trim_whitespace as trim_django
except ImportError:
trim_django = False
from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
from django.utils.translation import trim_whitespace
from django.utils.encoding import smart_text
from django.utils.translation.trans_real import (
inline_re, block_re, endblock_re, plural_re, constant_re)
def trim_whitespace(string):
"""Trim whitespace.
This is only supported in Django>=1.7. This method help in cases of older
Django versions.
"""
if trim_django:
return trim_django(string)
return string
def join_tokens(tokens, trim=False):
message = ''.join(tokens)
if trim:

View File

@ -2,10 +2,7 @@
from babel import Locale, UnknownLocaleError
from django.utils.translation import get_language
try:
from threading import local
except ImportError:
from django.utils._threading_local import local
from threading import local
__all__ = ['get_current_locale', 'LocaleMiddleware']