0
有没有办法停止执行并返回一个函数,而不是post,get,put?在post后返回httpresponse
因此,例如
class MyClass(View):
def post(self, request, *args, **kwargs):
test_some_things()
do_some_other_stuff()
return HttpResponse(..)
def test_some_things(self):
if test_fails:
return HttpResponse(..)
else:
return 1
我希望能够终止执行,如果test_fails,只是返回响应。但以上似乎并没有工作...
听起来像[这个问题](http://stackoverflow.com/q/14329219/473232)类似的概念。视图装饰器对你来说也许是正确的方法。 – dgel