引入模块:
from django.utils.decorators import method_decorator


添加:@method_decorator(func)
from django.utils.decorators import method_decorator
def outer(func):
def inner(request, *args, **kwargs):
print(request.method)
return func(request, *args, **kwargs)
return inner


class Login(views.View):

@method_decorator(outer)
def get(self, request, *args, **kwargs):

return render(request, 'login.html', {'message': ''})
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄