Julio Marins Julio Marins - 1 year ago 131
Python Question

How can I enable CORS on Django REST Framework

How can I enable CORS on my Django REST Framework?
the reference doesn't help much, it says that I can do by a middleware, but how can I do that?

Answer Source

The link you referenced in your question recommends using django-cors-headers, whose documentation says to install the library

pip install django-cors-headers

and then add it to your installed apps:


You will also need to add a middleware class to listen in on responses:


You might also want to browse the configuration section of its documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download