views.py
from django.http import HttpResponse
from django.views import View
from django.utils.decorators import method_decorator
@method_decorator(装饰器函数名,name='dispatch')
class Login(View):
@method_decorator(装饰器函数名)
def dispatch(self, request, *args, **kwargs):
print('get、post请求之前')
super(Login, self).dispatch(self, request, *args, **kwargs)
print('get、post请求之后')
return HttpResponse('OK')
@method_decorator(装饰器函数名)
def get(self, request, *args, **kwargs):
return HttpResponse('OK')
def post(self, request, *args, **kwargs):
return HttpResponse('OK')