Only add builtins template option on Django >= 1.9

This commit is contained in:
Stefan Wehrmeyer 2015-12-20 15:20:50 +01:00
parent f1b33a4b9d
commit 3ea8a8b991
2 changed files with 12 additions and 5 deletions

View File

@ -3,6 +3,6 @@
# be added to built-ins at start-up time, this is a good place to do it.
import django
if django.VERSION < (1,9):
if django.VERSION < (1, 9):
from django.template.base import add_to_builtins
add_to_builtins("overextends.templatetags.overextends_tags")

View File

@ -2,10 +2,11 @@
import os
import django
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
PROJECT_DIRNAME = PROJECT_ROOT.split(os.sep)[-1]
ROOT_URLCONF = "%s.urls" % PROJECT_DIRNAME
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"),)
try:
import django.test.runner
@ -26,15 +27,21 @@ TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"),)
TEMPLATE_OPTIONS = {}
if django.VERSION >= (1, 9):
# only set builtins option on Django >= 1.9
TEMPLATE_OPTIONS = {
'builtins': ['overextends.templatetags.overextends_tags'],
}
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'DIRS': TEMPLATE_DIRS,
'OPTIONS': {
'builtins': ['overextends.templatetags.overextends_tags'],
}
'OPTIONS': TEMPLATE_OPTIONS
},
]