Only add builtins template option on Django >= 1.9
This commit is contained in:
		| @@ -3,6 +3,6 @@ | |||||||
| # be added to built-ins at start-up time, this is a good place to do it. | # be added to built-ins at start-up time, this is a good place to do it. | ||||||
| import django | import django | ||||||
|  |  | ||||||
| if django.VERSION < (1,9): | if django.VERSION < (1, 9): | ||||||
|     from django.template.base import add_to_builtins |     from django.template.base import add_to_builtins | ||||||
|     add_to_builtins("overextends.templatetags.overextends_tags") |     add_to_builtins("overextends.templatetags.overextends_tags") | ||||||
|   | |||||||
| @@ -2,10 +2,11 @@ | |||||||
|  |  | ||||||
| import os | import os | ||||||
|  |  | ||||||
|  | import django | ||||||
|  |  | ||||||
| PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) | PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) | ||||||
| PROJECT_DIRNAME = PROJECT_ROOT.split(os.sep)[-1] | PROJECT_DIRNAME = PROJECT_ROOT.split(os.sep)[-1] | ||||||
| ROOT_URLCONF = "%s.urls" % PROJECT_DIRNAME | ROOT_URLCONF = "%s.urls" % PROJECT_DIRNAME | ||||||
| TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"),) |  | ||||||
|  |  | ||||||
| try: | try: | ||||||
|     import django.test.runner |     import django.test.runner | ||||||
| @@ -26,15 +27,21 @@ TEMPLATE_LOADERS = ( | |||||||
|     'django.template.loaders.filesystem.Loader', |     'django.template.loaders.filesystem.Loader', | ||||||
|     'django.template.loaders.app_directories.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 = [ | TEMPLATES = [ | ||||||
|     { |     { | ||||||
|         'BACKEND': 'django.template.backends.django.DjangoTemplates', |         'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||||||
|         'APP_DIRS': True, |         'APP_DIRS': True, | ||||||
|         'DIRS': TEMPLATE_DIRS, |         'DIRS': TEMPLATE_DIRS, | ||||||
|         'OPTIONS': { |         'OPTIONS': TEMPLATE_OPTIONS | ||||||
|             'builtins': ['overextends.templatetags.overextends_tags'], |  | ||||||
|         } |  | ||||||
|     }, |     }, | ||||||
| ] | ] | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Stefan Wehrmeyer
					Stefan Wehrmeyer