-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompat.py
More file actions
27 lines (21 loc) · 772 Bytes
/
compat.py
File metadata and controls
27 lines (21 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
try:
from django.template.engine import Engine
from django.template.loaders.base import Loader as BaseLoader
except ImportError: # Django < 1.8
Engine = None
from django.template.loader import BaseLoader, find_template_loader, get_template_from_string
def template_loader(loader_name):
if Engine:
return Engine.get_default().find_template_loader(loader_name)
else: # Django < 1.8
return find_template_loader(loader_name)
def template_from_string(template_code):
if Engine:
return Engine().from_string(template_code)
else: # Django < 1.8
return get_template_from_string(template_code)
def get_engine():
if Engine:
return Engine.get_default()
else: # Django < 1.8
return None