剂量Django hava在烧瓶中的功能如“abort”?我想在处理请求参数时打破请求

问题描述 投票:-3回答:1

我想在Django处理请求参数更优雅,这是我的代码:qazxsw poi

有了它,我可以在我的视图功能中使用这样的:

enter image description here

然后我运行了我的Django应用程序并在chrome中输入了url(def testparam(request): name = request_get(request, 'name', required=True) age = request_get(request, 'age', ptype=int, required=True) print('name: ', name) print('age: ', age) return HttpResponse('test param run') ),但我仍然得到了“test param run”的响应。我希望我的django在request_get函数调用就像在flask框架中的abort函数时做出响应。有人可以帮帮我吗?

python django
1个回答
0
投票

我通过使用http://127.0.0.1:8000/test/param提示自定义异常和异常中间件来解决问题

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.