Fix errors in django 1.8 and below
This commit is contained in:
@@ -18,8 +18,9 @@ def handle_extendsnode(extendsnode, context):
|
|||||||
all blocks tags with the nodes of appropriate blocks.
|
all blocks tags with the nodes of appropriate blocks.
|
||||||
Also handles {{ block.super }} tags.
|
Also handles {{ block.super }} tags.
|
||||||
"""
|
"""
|
||||||
context.render_context.setdefault(BLOCK_CONTEXT_KEY, BlockContext())
|
if BLOCK_CONTEXT_KEY not in context.render_context:
|
||||||
block_context = context.render_context.get(BLOCK_CONTEXT_KEY)
|
context.render_context[BLOCK_CONTEXT_KEY] = BlockContext()
|
||||||
|
block_context = context.render_context[BLOCK_CONTEXT_KEY]
|
||||||
blocks = dict((n.name, n) for n in
|
blocks = dict((n.name, n) for n in
|
||||||
extendsnode.nodelist.get_nodes_by_type(BlockNode))
|
extendsnode.nodelist.get_nodes_by_type(BlockNode))
|
||||||
block_context.add_blocks(blocks)
|
block_context.add_blocks(blocks)
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import unittest
|
|||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
from mock import patch
|
from mock import patch
|
||||||
from unittest import SkipTest
|
from unittest import SkipTest, skipIf
|
||||||
|
|
||||||
|
from django import VERSION as DJANGO_VERSION
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
from django.template import Template, Context
|
from django.template import Template, Context
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
@@ -632,6 +633,7 @@ class OfflineCompressComplexTestCase(OfflineTestCaseMixin, TestCase):
|
|||||||
self.assertEqual(rendered_template, ''.join(result) + '\n')
|
self.assertEqual(rendered_template, ''.join(result) + '\n')
|
||||||
|
|
||||||
|
|
||||||
|
@skipIf(DJANGO_VERSION[0] <= 1 and DJANGO_VERSION[1] < 9, "Needs Django >= 1.9, recursive templates were fixed in Django 1.9")
|
||||||
class OfflineCompressExtendsRecursionTestCase(OfflineTestCaseMixin, TestCase):
|
class OfflineCompressExtendsRecursionTestCase(OfflineTestCaseMixin, TestCase):
|
||||||
"""
|
"""
|
||||||
Test that templates extending templates with the same name
|
Test that templates extending templates with the same name
|
||||||
|
|||||||
Reference in New Issue
Block a user