Skip to content

Commit

Permalink
Fix the issue that cache_key method signature is changed in Django 1.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfg1969 committed Apr 24, 2016
1 parent 26f0a09 commit 7b15d2c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions django_mobile/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,17 @@ def template_source_loaders(self):
class CachedLoader(DjangoCachedLoader):
is_usable = True

def cache_key(self, template_name, template_dirs):
if template_dirs:
key = '-'.join([
template_name,
hashlib.sha1(force_bytes('|'.join(template_dirs))).hexdigest()
])
def cache_key(self, template_name, template_dirs, *args):
if len(args) > 0: # Django >= 1.9
key = super(CachedLoader, self).cache_key(template_name, template_dirs, *args)
else:
key = template_name
if template_dirs:
key = '-'.join([
template_name,
hashlib.sha1(force_bytes('|'.join(template_dirs))).hexdigest()
])
else:
key = template_name

return '{0}:{1}'.format(get_flavour(), key)

Expand Down

0 comments on commit 7b15d2c

Please sign in to comment.