如何在django中提出禁止的响应 [英] How do I raise a Response Forbidden in django

查看:69
本文介绍了如何在django中提出禁止的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行以下操作:

raise HttpResponseForbidden()

但是我收到错误:

exceptions must be old-style classes or derived from BaseException, not HttpResponseForbidden

我该怎么做? p>

How should I do this?

推荐答案

从任何其他响应中返回它。

Return it from the view as you would any other response.

from django.http import HttpResponseForbidden

return HttpResponseForbidden()

这篇关于如何在django中提出禁止的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆