From d3fd28c91ab948705a5d62c49631451fd9eb270d Mon Sep 17 00:00:00 2001 From: Wijnand Modderman-Lenstra Date: Wed, 4 Apr 2012 21:15:53 +0200 Subject: [PATCH] Check for context_data on the response object, we might be dealing with a HttpResponseRedirect for example. --- djpjax.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/djpjax.py b/djpjax.py index 6cc559c..0e62227 100644 --- a/djpjax.py +++ b/djpjax.py @@ -29,10 +29,11 @@ def _view(request, *args, **kwargs): # if not hasattr(resp, "is_rendered"): # warnings.warn("@pjax used with non-template-response view") # return resp - if request.META.get('HTTP_X_PJAX', False): - resp.context_data[context_var] = pjax_parent - elif parent: - resp.context_data[context_var] = parent + if hasattr(resp, 'context_data'): + if request.META.get('HTTP_X_PJAX', False): + resp.context_data[context_var] = pjax_parent + elif parent: + resp.context_data[context_var] = parent return resp return _view return pjaxtend_decorator