重定向+ 403错误 [英] Redirection + 403 error
本文介绍了重定向+ 403错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
返回HttpResponseForbiddenRedirect(reverse(view_name))
一个HttpResponse重定向到一个视图(带有它的名字),但仍然抛出一个403错误
我尝试这样做:
class HttpResponseForbiddenRedirect(HttpResponse):
def __init __(self,redirect_to):
super(HttpResponseForbiddenRedirect,self).__ init __()
self ['Location'] = iri_to_uri(redirect_to)
self.status_code = 403
但它没有工作。因为某些原因我不明白,我没有得到任何内容
解决方案
我找到了一个解决方案: p>
from app_name.views import my_view
....
retour = my_views(request)
return HttpResponseForbidden(retour)
其实很简单
所以我得到403错误+我想加载的页面
I am searching for a way to have something like that :
return HttpResponseForbiddenRedirect(reverse("view_name"))
an HttpResponse which redirect to a view (with its name) but still throw a 403 error
I tried to do something like that :
class HttpResponseForbiddenRedirect(HttpResponse):
def __init__(self, redirect_to):
super(HttpResponseForbiddenRedirect, self).__init__()
self['Location'] = iri_to_uri(redirect_to)
self.status_code = 403
But it didn't work. For some reason I don't understand, I don't get any content
解决方案
I found a solution to this :
from app_name.views import my_view
....
retour = my_views(request)
return HttpResponseForbidden(retour)
It is in fact quite simple
And so I get the 403 error + the page I wanna load
这篇关于重定向+ 403错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文