Merge pull request #2683 from aadithpm/master

This commit is contained in:
Bruno Alla 2020-07-24 16:47:42 +01:00 committed by GitHub
commit 8d5542d675
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -44,6 +44,7 @@ Listed in alphabetical order.
18 `@dezoito`_ 18 `@dezoito`_
2O4 `@2O4`_ 2O4 `@2O4`_
a7p `@a7p`_ a7p `@a7p`_
Aadith PM `@aadithpm`_
Aaron Eikenberry `@aeikenberry`_ Aaron Eikenberry `@aeikenberry`_
Adam Bogdał `@bogdal`_ Adam Bogdał `@bogdal`_
Adam Dobrawy `@ad-m`_ Adam Dobrawy `@ad-m`_
@ -235,6 +236,7 @@ Listed in alphabetical order.
Yuchen Xie `@mapx`_ Yuchen Xie `@mapx`_
========================== ============================ ============== ========================== ============================ ==============
.. _@aadithpm: https://github.com/aadithpm
.. _@a7p: https://github.com/a7p .. _@a7p: https://github.com/a7p
.. _@2O4: https://github.com/2O4 .. _@2O4: https://github.com/2O4
.. _@ad-m: https://github.com/ad-m .. _@ad-m: https://github.com/ad-m

View File

@ -80,6 +80,7 @@ THIRD_PARTY_APPS = [
{%- if cookiecutter.use_drf == "y" %} {%- if cookiecutter.use_drf == "y" %}
"rest_framework", "rest_framework",
"rest_framework.authtoken", "rest_framework.authtoken",
"corsheaders",
{%- endif %} {%- endif %}
] ]
@ -134,6 +135,9 @@ AUTH_PASSWORD_VALIDATORS = [
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware # https://docs.djangoproject.com/en/dev/ref/settings/#middleware
MIDDLEWARE = [ MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
{%- if cookiecutter.use_drf == 'y' %}
"corsheaders.middleware.CorsMiddleware",
{%- endif %}
{%- if cookiecutter.use_whitenoise == 'y' %} {%- if cookiecutter.use_whitenoise == 'y' %}
"whitenoise.middleware.WhiteNoiseMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware",
{%- endif %} {%- endif %}
@ -321,6 +325,10 @@ REST_FRAMEWORK = {
), ),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",), "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
} }
# django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup
CORS_URLS_REGEX = r"^/api/.*$"
{%- endif %} {%- endif %}
# Your stuff... # Your stuff...
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -41,4 +41,6 @@ django-redis==4.12.1 # https://github.com/jazzband/django-redis
{%- if cookiecutter.use_drf == "y" %} {%- if cookiecutter.use_drf == "y" %}
# Django REST Framework # Django REST Framework
djangorestframework==3.11.0 # https://github.com/encode/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 %} {%- endif %}