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