3

I'm using django-pjax, and I'm not sure how I should be redirecting from within a view that could also return a pjax response.

If I use the redirect shortcut, I get:

AttributeError: 'HttpResponseRedirect' object has no attribute 'template_name'

Probably because django-pjax requres a TemplateResponse object, not a HttpResponse object. But since TemplateResponse objects don't handle redirects, I'm not sure what to do.

Any guidance is appreciated!

1
  • Are you trying to send the browser to a completely new URL? Or load content located at the redirected url using pjax? You might have to skip using the decorator for these views. Mar 27, 2014 at 19:46

1 Answer 1

0

At your front-end try this type of redirecting:

$.pjax({url: $('.logo').attr('href'), container: '#w0'});

Replace $('.logo').attr('href') to your url and #w0 to your container ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.