Ticket #23789: ticket_23789.patch

File ticket_23789.patch, 1.4 KB (added by Luke Plant, 10 years ago)

Patch implementing bug fix

  • django/template/response.py

    diff --git a/django/template/response.py b/django/template/response.py
    index f65c3ad..f43a4e0 100644
    a b class TemplateResponse(SimpleTemplateResponse):  
    154154        """
    155155        if isinstance(context, Context):
    156156            return context
    157         return RequestContext(self._request, context, current_app=self._current_app)
     157        context_instance = RequestContext(self._request, current_app=self._current_app)
     158        if context:
     159            context_instance.push(context)
     160        return context_instance
  • tests/template_tests/test_response.py

    diff --git a/tests/template_tests/test_response.py b/tests/template_tests/test_response.py
    index 8791a11..d7dd3f4 100644
    a b class TemplateResponseTest(TestCase):  
    233233                                  Context({'foo': 'bar'})).render()
    234234        self.assertEqual(response.content, b'bar')
    235235
     236    def test_context_processor_priority(self):
     237        # context processors should be overridden by passed-in context
     238        response = self._response('{{ foo }}{{ processors }}',
     239                                  {'processors': 'no'}).render()
     240        self.assertEqual(response.content, b'no')
     241
    236242    def test_kwargs(self):
    237243        response = self._response(content_type='application/json',
    238244                                  status=504)
Back to Top