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之前价捧。
設(shè)置參數(shù)為True
CORS_ORIGIN_ALLOW_ALL = True