跨域请求csrf_exempt

==========urls中设置===============

from django.conf.urls import url

from django.views.decorators.csrf import csrf_exempt

import views

urlpatterns = [ url(r'^myview/$', csrf_exempt(views.MyView.as_view()), name='myview'), ]

 

 

 

from django.views.decorators.csrf import csrf_exempt

==========继承视图类的类视图======

class productlist(View):

@csrf_exempt
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
posted @ 2021-09-09 09:59  关美丽  阅读(352)  评论(0编辑  收藏  举报