# -*- coding: utf-8 -*-

from django.core.cache import get_cache
from django.utils.functional import cached_property
from jinja2 import BytecodeCache as _BytecodeCache


class BytecodeCache(_BytecodeCache):
    """
    A bytecode cache for Jinja2 that uses Django's caching framework.
    """

    def __init__(self, cache_name):
        self._cache_name = cache_name

    @cached_property
    def backend(self):
        return get_cache(self._cache_name)

    def load_bytecode(self, bucket):
        key = 'jinja2_%s' % str(bucket.key)
        bytecode = self.backend.get(key)
        if bytecode:
            bucket.bytecode_from_string(bytecode)

    def dump_bytecode(self, bucket):
        key = 'jinja2_%s' % str(bucket.key)
        self.backend.set(key, bucket.bytecode_to_string())

@@ -21,48 +21,21 @@
 -*-%0A
-%0Afrom
+import
  django
-.core.cache import get_cache
 %0Afro
@@ -391,42 +391,245 @@
     
-return get_cache(self._cache_name)
+if django.VERSION%5B:2%5D %3C (1, 8):%0A            from django.core.cache import get_cache%0A            return get_cache(self._cache_name)%0A        else:%0A            from django.core.cache import caches%0A            return caches%5Bself._cache_name%5D
 %0A%0A  

fix deprecation warnings in django 1.8 for get cache function