django-cors-headers
Django app for handling the server headers required for Cross-Origin Resource Sharing (CORS)
pip install django-cors-headers
INSTALLED_APPS = (
...
'corsheaders',
...
)
然后添加我们的middleware,要放的尽可能靠前,在csrfview之前。
设置参数为True
CORS_ORIGIN_ALLOW_ALL = True