From a6779caf1cd35984dfb9c7c5b4cc77b7112bd3cc Mon Sep 17 00:00:00 2001 From: James Cleveland Date: Tue, 12 Jun 2012 14:51:24 +0100 Subject: [PATCH] Edited pjaxtend decorator in order for it to not crash when there are responses returned such as HttpResponse, that do not have a context_data attribute. --- djpjax.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/djpjax.py b/djpjax.py index 6cc559c..403efa9 100644 --- a/djpjax.py +++ b/djpjax.py @@ -29,10 +29,13 @@ 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 + try: + if request.META.get('HTTP_X_PJAX', False): + resp.context_data[context_var] = pjax_parent + elif parent: + resp.context_data[context_var] = parent + except AttributeError: + pass return resp return _view return pjaxtend_decorator