开发者

How should redirects be handled with django-pjax?

开发者 https://www.devze.com 2023-03-18 01:51 出处:网络
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.

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:

开发者_StackOverflowAttributeError: '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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消