方式一:from django.views.decorators.csrf import csrf_exemptfrom django.utils.decorators import method_decoratorfrom django.views import Viewclass Goods_v ...
方式一:
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
from django.views import View
class Goods_views(View):
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super(Goods_views,self).dispatch(request, *args, **kwargs)
def post(request):
pass
註:上述代碼除了類名(Goods_views)可以替換。其他均不可更改。
方式二:
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator
from django.views import View
@method_decorator(csrf_exempt,name='dispatch')
class Goods_views(View):
def post(request):
pass