Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix TEMPLATE_LOADERS attribute error for Django > 1.8 #76

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion django_mobile/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from django import VERSION as django_version
from django.conf import settings as django_settings

CACHE_LOADER_NAME = 'django_mobile.loader.CachedLoader'
Expand Down Expand Up @@ -30,7 +31,16 @@ class defaults(object):
FLAVOURS_COOKIE_HTTPONLY = False
FLAVOURS_SESSION_KEY = u'flavour'
FLAVOURS_TEMPLATE_LOADERS = []
for loader in django_settings.TEMPLATE_LOADERS:

if django_version >= (1, 8):
loaders = []
for template_engine in django_settings.TEMPLATES:
loaders += template_engine.get('OPTIONS', {}).get('loaders', [])
DEFAULT_TEMPLATE_LOADERS = loaders
else:
DEFAULT_TEMPLATE_LOADERS = django_settings.TEMPLATE_LOADERS

for loader in DEFAULT_TEMPLATE_LOADERS:
if isinstance(loader, (tuple, list)) and loader[0] == CACHE_LOADER_NAME:
for cached_loader in loader[1]:
if cached_loader != DJANGO_MOBILE_LOADER:
Expand Down