Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update requirements to include django-cors-headers with DRF [PR #2650] #2683

Merged
merged 6 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Listed in alphabetical order.
18 `@dezoito`_
2O4 `@2O4`_
a7p `@a7p`_
Aadith PM `@aadithpm`_
Aaron Eikenberry `@aeikenberry`_
Adam Bogdał `@bogdal`_
Adam Dobrawy `@ad-m`_
Expand Down Expand Up @@ -235,6 +236,7 @@ Listed in alphabetical order.
Yuchen Xie `@mapx`_
========================== ============================ ==============

.. _@aadithpm: https://github.com/aadithpm
.. _@a7p: https://github.com/a7p
.. _@2O4: https://github.com/2O4
.. _@ad-m: https://github.com/ad-m
Expand Down
8 changes: 8 additions & 0 deletions {{cookiecutter.project_slug}}/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
{%- if cookiecutter.use_drf == "y" %}
"rest_framework",
"rest_framework.authtoken",
"corsheaders",
{%- endif %}
]

Expand Down Expand Up @@ -134,6 +135,9 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
{%- if cookiecutter.use_drf == 'y' %}
"corsheaders.middleware.CorsMiddleware",
{%- endif %}
{%- if cookiecutter.use_whitenoise == 'y' %}
"whitenoise.middleware.WhiteNoiseMiddleware",
{%- endif %}
Expand Down Expand Up @@ -321,6 +325,10 @@
),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
}

# django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup
CORS_URLS_REGEX = r"^/api/.*$"

{%- endif %}
# Your stuff...
# ------------------------------------------------------------------------------
2 changes: 2 additions & 0 deletions {{cookiecutter.project_slug}}/requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ django-redis==4.12.1 # https://github.com/jazzband/django-redis
{%- if cookiecutter.use_drf == "y" %}
# Django REST Framework
djangorestframework==3.11.0 # https://github.com/encode/django-rest-framework
# Django CORS Headers
django-cors-headers==0.01 # https://github.com/adamchainz/django-cors-headers
{%- endif %}