例如,我有一个基于类的视图,它允许 GET 和 POST 方法,如下所示,
class ViewOne(View):
def post(self, request, *args, **kwargs):
...
def get(self, request, *args, **kwargs):
...
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(ViewOne, self).dispatch(*args, **kwargs)
现在,GET 和 POST 都是 login_required。但是如果我只希望 POST 是 login_required 怎么办?