github的连接:https://github.com/ottoyiu/django-cors-headers
第一步安装包:
pip install django-cors-headers
第二步配置APP:
INSTALLED_APPS = (
...
'corsheaders',
...
)
第三步配置MIDDLEWARE :
MIDDLEWARE = [ # Or MIDDLEWARE_CLASSES on Django < 1.10
...
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
...
]
第四部配置CORS_ORIGIN_ALLOW_ALL: