跨域请求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)