From 9cf47898f41b135b390f5e27c9c52b4a85fe6a8d Mon Sep 17 00:00:00 2001 From: Sudarshan Wadkar Date: Fri, 24 Apr 2020 14:00:27 +0530 Subject: [PATCH 01/82] Only consider TLDs while adding `www` route Instead of checking for `.co.XX` on best effort basis, we only check for the single dot in the domain_name indicating no subdomain usage. --- .../compose/production/traefik/traefik.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml index 5ff2e363..cfd566a8 100644 --- a/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml +++ b/{{cookiecutter.project_slug}}/compose/production/traefik/traefik.yml @@ -26,10 +26,9 @@ certificatesResolvers: entryPoint: web http: - {%- set domain_dots = cookiecutter.domain_name.count('.') %} routers: web-router: - {%- if domain_dots == 1 or (domain_dots == 2 and '.co.' in cookiecutter.domain_name) %} + {%- if cookiecutter.domain_name.count('.') == 1 %} rule: "Host(`{{ cookiecutter.domain_name }}`) || Host(`www.{{ cookiecutter.domain_name }}`)" {% else %} rule: "Host(`{{ cookiecutter.domain_name }}`)" @@ -42,7 +41,7 @@ http: service: django web-secure-router: - {%- if domain_dots == 1 or (domain_dots == 2 and '.co.' in cookiecutter.domain_name) %} + {%- if cookiecutter.domain_name.count('.') == 1 %} rule: "Host(`{{ cookiecutter.domain_name }}`) || Host(`www.{{ cookiecutter.domain_name }}`)" {% else %} rule: "Host(`{{ cookiecutter.domain_name }}`)" From 1838ba37e0c74dd2c75225c1b02c157f02d378b0 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 24 Apr 2020 15:38:20 +0100 Subject: [PATCH 02/82] Remove the labeler workflow, it's broken with forks --- .github/labeler.yml | 11 ----------- .github/workflows/label.yml | 20 -------------------- 2 files changed, 31 deletions(-) delete mode 100644 .github/labeler.yml delete mode 100644 .github/workflows/label.yml diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index a29e237d..00000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Add 'docs' to any changes within 'docs' folder or any subfolders -docs: - - 'README.rst' - - 'docs/**/*' - - '{{cookiecutter.project_slug}}/docs/**/*' - -# Flag PR related to docker -docker: - - '{{cookiecutter.project_slug}}/compose/**/*' - - '{{cookiecutter.project_slug}}/local.yml' - - '{{cookiecutter.project_slug}}/production.yml' diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml deleted file mode 100644 index 3df0ec0c..00000000 --- a/.github/workflows/label.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This workflow will triage pull requests and apply a label based on the -# paths that are modified in the pull request. -# -# To use this workflow, you will need to set up a .github/labeler.yml -# file with configuration. For more information, see: -# https://github.com/actions/labeler/blob/master/README.md - - -name: Labeler -on: [pull_request] - -jobs: - label: - - runs-on: ubuntu-latest - - steps: - - uses: actions/labeler@v2 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" From f9c20af456750977f52927d30bbfa496a26d28da Mon Sep 17 00:00:00 2001 From: Hannah Lazarus Date: Thu, 16 Apr 2020 09:45:24 -0400 Subject: [PATCH 03/82] Add container_names for docker commands container_names make it possible to run docker commands without looking up container hash use in dev.yml --- CONTRIBUTORS.rst | 1 + docs/developing-locally-docker.rst | 9 +++++++++ {{cookiecutter.project_slug}}/local.yml | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 86b529eb..660ffc68 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -128,6 +128,7 @@ Listed in alphabetical order. Guilherme Guy `@guilherme1guy`_ Hamish Durkin `@durkode`_ Hana Quadara `@hanaquadara`_ + Hannah Lazarus `@hanhanhan`_ Harry Moreno `@morenoh149`_ @morenoh149 Harry Percival `@hjwp`_ Hendrik Schneider `@hendrikschneider`_ diff --git a/docs/developing-locally-docker.rst b/docs/developing-locally-docker.rst index 09e68498..d6b4146d 100644 --- a/docs/developing-locally-docker.rst +++ b/docs/developing-locally-docker.rst @@ -154,6 +154,15 @@ django-debug-toolbar In order for ``django-debug-toolbar`` to work designate your Docker Machine IP with ``INTERNAL_IPS`` in ``local.py``. +docker +"""""" + +The ``container_name`` from the yml file can be used to check on containers with docker commands, for example: :: + + $ docker logs worker + $ docker top worker + + Mailhog ~~~~~~~ diff --git a/{{cookiecutter.project_slug}}/local.yml b/{{cookiecutter.project_slug}}/local.yml index 60f8f922..b603f177 100644 --- a/{{cookiecutter.project_slug}}/local.yml +++ b/{{cookiecutter.project_slug}}/local.yml @@ -10,6 +10,7 @@ services: context: . dockerfile: ./compose/local/django/Dockerfile image: {{ cookiecutter.project_slug }}_local_django + container_name: django depends_on: - postgres {%- if cookiecutter.use_mailhog == 'y' %} @@ -29,6 +30,7 @@ services: context: . dockerfile: ./compose/production/postgres/Dockerfile image: {{ cookiecutter.project_slug }}_production_postgres + container_name: postgres volumes: - local_postgres_data:/var/lib/postgresql/data - local_postgres_data_backups:/backups @@ -38,6 +40,7 @@ services: mailhog: image: mailhog/mailhog:v1.0.0 + container_name: mailhog ports: - "8025:8025" @@ -46,10 +49,12 @@ services: redis: image: redis:5.0 + container_name: redis celeryworker: <<: *django image: {{ cookiecutter.project_slug }}_local_celeryworker + container_name: celeryworker depends_on: - redis - postgres @@ -62,6 +67,7 @@ services: celerybeat: <<: *django image: {{ cookiecutter.project_slug }}_local_celerybeat + container_name: celerybeat depends_on: - redis - postgres @@ -74,6 +80,7 @@ services: flower: <<: *django image: {{ cookiecutter.project_slug }}_local_flower + container_name: flower ports: - "5555:5555" command: /start-flower @@ -86,6 +93,7 @@ services: context: . dockerfile: ./compose/local/node/Dockerfile image: {{ cookiecutter.project_slug }}_local_node + container_name: node depends_on: - django volumes: From 95ca7ca29171fc98307219d3d95257e736528635 Mon Sep 17 00:00:00 2001 From: Tano Abeleyra Date: Fri, 24 Apr 2020 21:29:59 -0300 Subject: [PATCH 04/82] Update django-redis links --- {{cookiecutter.project_slug}}/config/settings/production.py | 2 +- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index cea29b8e..c13f1aeb 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -34,7 +34,7 @@ CACHES = { "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", # Mimicing memcache behavior. - # http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior + # http://jazzband.github.io/django-redis/latest/#_memcached_exceptions_behavior "IGNORE_EXCEPTIONS": True, }, } diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 896110c2..62db8c79 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -31,7 +31,7 @@ django-crispy-forms==1.9.0 # https://github.com/django-crispy-forms/django-cris {%- if cookiecutter.use_compressor == "y" %} django-compressor==2.4 # https://github.com/django-compressor/django-compressor {%- endif %} -django-redis==4.11.0 # https://github.com/niwinz/django-redis +django-redis==4.11.0 # 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 From b8a1805a9fd4dd81f798d34bb67143d63d867bc4 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sun, 26 Apr 2020 12:00:30 +0100 Subject: [PATCH 05/82] Update pillow from 7.1.1 to 7.1.2 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 62db8c79..0a81a003 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -1,6 +1,6 @@ pytz==2019.3 # https://github.com/stub42/pytz python-slugify==4.0.0 # https://github.com/un33k/python-slugify -Pillow==7.1.1 # https://github.com/python-pillow/Pillow +Pillow==7.1.2 # https://github.com/python-pillow/Pillow {%- if cookiecutter.use_compressor == "y" %} rcssmin==1.0.6{% if cookiecutter.windows == 'y' and cookiecutter.use_docker == 'n' %} --install-option="--without-c-extensions"{% endif %} # https://github.com/ndparker/rcssmin {%- endif %} From 393526bc4795be176d2a86944e77904c0085a497 Mon Sep 17 00:00:00 2001 From: Jonathan Thompson Date: Mon, 27 Apr 2020 02:31:46 +0000 Subject: [PATCH 06/82] Clarify the installation steps for local setup Added a link to Cookiecutter as a prerequisite. Added an installation command for cookiecutter-django. Added a command for git init. The precommit install fails unless you have a git repo. This should make it easier for a newcomer to get things configured. --- docs/developing-locally.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index 4f70414c..dc146c23 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -12,6 +12,7 @@ Make sure to have the following on your host: * Python 3.8 * PostgreSQL_. * Redis_, if using Celery +* Cookiecutter_ First things first. @@ -23,9 +24,14 @@ First things first. $ source /bin/activate +#. Install cookiecutter-django + + $ cookiecutter gh:pydanny/cookiecutter-django :: + #. Install development requirements: :: $ pip install -r requirements/local.txt + $ git init # A git repo is required for pre-commit to install $ pre-commit install .. note:: @@ -78,6 +84,7 @@ or if you're running asynchronously: :: .. _PostgreSQL: https://www.postgresql.org/download/ .. _Redis: https://redis.io/download +.. _CookieCutter: https://github.com/cookiecutter/cookiecutter .. _createdb: https://www.postgresql.org/docs/current/static/app-createdb.html .. _initial PostgreSQL set up: http://suite.opengeo.org/docs/latest/dataadmin/pgGettingStarted/firstconnect.html .. _postgres documentation: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html From a34e3a53c66f7953dbc03d010e4685b41272bfa3 Mon Sep 17 00:00:00 2001 From: Jonathan Thompson Date: Mon, 27 Apr 2020 02:38:51 +0000 Subject: [PATCH 07/82] Update CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 86b529eb..39e05c3f 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -145,6 +145,7 @@ Listed in alphabetical order. Jerome Leclanche `@jleclanche`_ @Adys Jimmy Gitonga `@afrowave`_ @afrowave John Cass `@jcass77`_ @cass_john + Jonathan Thompson `@nojanath`_ Jules Cheron `@jules-ch`_ Julien Almarcha `@sladinji`_ Julio Castillo `@juliocc`_ @@ -357,6 +358,7 @@ Listed in alphabetical order. .. _@myilmaz: https://github.com/myilmaz .. _@nicolas471: https://github.com/nicolas471 .. _@noisy: https://github.com/noisy +.. _@nojanath: https://github.com/nojanath .. _@originell: https://github.com/originell .. _@oubiga: https://github.com/oubiga .. _@parbhat: https://github.com/parbhat From 04d8b06035bb052f05147c160f303e33fd119729 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 27 Apr 2020 12:00:31 +0100 Subject: [PATCH 08/82] Update sphinx from 3.0.2 to 3.0.3 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index f6be44b5..bf78bce0 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.1 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb -Sphinx==3.0.2 # https://github.com/sphinx-doc/sphinx +Sphinx==3.0.3 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From 3d8c4627f4cc7a49cb6a63b1bec2990f1397aaa5 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Mon, 27 Apr 2020 12:00:36 +0100 Subject: [PATCH 09/82] Update pytest-sugar from 0.9.2 to 0.9.3 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index f6be44b5..9cc7111d 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -14,7 +14,7 @@ psycopg2-binary==2.8.5 # https://github.com/psycopg/psycopg2 mypy==0.770 # https://github.com/python/mypy django-stubs==1.5.0 # https://github.com/typeddjango/django-stubs pytest==5.3.5 # https://github.com/pytest-dev/pytest -pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar +pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar # Code quality # ------------------------------------------------------------------------------ From 84d871a1cdcd5118e3ea31dd86f08b8cdabd5cc0 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 27 Apr 2020 11:40:16 -0700 Subject: [PATCH 10/82] Update sh from 1.12.14 to 1.13.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c5601892..ddd77cec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ cookiecutter==1.7.2 -sh==1.12.14 +sh==1.13.0 binaryornot==0.4.4 # Code quality From f13f3dc2bf16f8fe40d6bb10b89846ce8c8bb503 Mon Sep 17 00:00:00 2001 From: Pilhwan Kim Date: Tue, 28 Apr 2020 12:41:51 +0900 Subject: [PATCH 11/82] add use drf tests --- hooks/post_gen_project.py | 2 ++ .../users/tests/test_drf_urls.py | 24 +++++++++++++++ .../users/tests/test_drf_views.py | 30 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_urls.py create mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ad1db3ee..21d680e0 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -299,6 +299,8 @@ def remove_aws_dockerfile(): def remove_drf_starter_files(): os.remove(os.path.join("config", "api_router.py")) shutil.rmtree(os.path.join("{{cookiecutter.project_slug}}", "users", "api")) + os.remove(os.path.join("{{cookiecutter.project_slug}}", "users", "tests", "test_drf_urls.py")) + os.remove(os.path.join("{{cookiecutter.project_slug}}", "users", "tests", "test_drf_views.py")) def remove_storages_module(): diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_urls.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_urls.py new file mode 100644 index 00000000..83b623f4 --- /dev/null +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_urls.py @@ -0,0 +1,24 @@ +import pytest +from django.urls import resolve, reverse + +from {{ cookiecutter.project_slug }}.users.models import User + +pytestmark = pytest.mark.django_db + + +def test_user_detail(user: User): + assert ( + reverse("api:user-detail", kwargs={"username": user.username}) + == f"/api/users/{user.username}/" + ) + assert resolve(f"/api/users/{user.username}/").view_name == "api:user-detail" + + +def test_user_list(): + assert reverse("api:user-list") == "/api/users/" + assert resolve("/api/users/").view_name == "api:user-list" + + +def test_user_me(): + assert reverse("api:user-me") == "/api/users/me/" + assert resolve("/api/users/me/").view_name == "api:user-me" diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py new file mode 100644 index 00000000..89c3c1a9 --- /dev/null +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py @@ -0,0 +1,30 @@ +import pytest +from django.test import RequestFactory + +from {{ cookiecutter.project_slug }}.users.models import User +from {{ cookiecutter.project_slug }}.users.api.views import UserViewSet +from {{ cookiecutter.project_slug }}.users.api.serializers import UserSerializer + +pytestmark = pytest.mark.django_db + + +class TestUserViewSet: + def test_get_queryset(self, user: User, rf: RequestFactory): + view = UserViewSet() + request = rf.get("/fake-url/") + request.user = user + + view.request = request + + assert user in view.get_queryset() + + def test_me(self, user: User, rf: RequestFactory): + view = UserViewSet() + request = rf.get("/fake-url/") + request.user = user + + view.request = request + + response = view.me(request) + + assert response.data == UserSerializer(user, context={"request": request}).data From 0c2af32b8d9808e443e36bde52f85d1b5b8e4893 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Tue, 28 Apr 2020 12:00:34 +0100 Subject: [PATCH 12/82] Update pytz from 2019.3 to 2020.1 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 0a81a003..b9e26d39 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -1,4 +1,4 @@ -pytz==2019.3 # https://github.com/stub42/pytz +pytz==2020.1 # https://github.com/stub42/pytz python-slugify==4.0.0 # https://github.com/un33k/python-slugify Pillow==7.1.2 # https://github.com/python-pillow/Pillow {%- if cookiecutter.use_compressor == "y" %} From 4eb718c6837888c19abbd59e4080ee38e40baa25 Mon Sep 17 00:00:00 2001 From: browniebroke Date: Sat, 14 Mar 2020 11:00:30 +0000 Subject: [PATCH 13/82] Update pytest from 5.3.5 to 5.4.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index d4d9897b..e3d013dc 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -13,7 +13,7 @@ psycopg2-binary==2.8.5 # https://github.com/psycopg/psycopg2 # ------------------------------------------------------------------------------ mypy==0.770 # https://github.com/python/mypy django-stubs==1.5.0 # https://github.com/typeddjango/django-stubs -pytest==5.3.5 # https://github.com/pytest-dev/pytest +pytest==5.4.1 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar # Code quality From f402437fb543d07902e3571fea31bb7b6f2f361f Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 28 Apr 2020 12:49:05 +0100 Subject: [PATCH 14/82] Fix broken link in CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 5f2de471..54031c30 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -313,6 +313,7 @@ Listed in alphabetical order. .. _@hackebrot: https://github.com/hackebrot .. _@hairychris: https://github.com/hairychris .. _@hanaquadara: https://github.com/hanaquadara +.. _@hanhanhan: https://github.com/hanhanhan .. _@hendrikschneider: https://github.com/hendrikschneider .. _@highpost: https://github.com/highpost .. _@hjwp: https://github.com/hjwp From ed60aa36ee39b5ade0c2e2ad2798c4197e45bced Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 28 Apr 2020 07:40:23 -0700 Subject: [PATCH 15/82] Update sh from 1.13.0 to 1.13.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ddd77cec..18439a35 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ cookiecutter==1.7.2 -sh==1.13.0 +sh==1.13.1 binaryornot==0.4.4 # Code quality From c54c4f5ef7ebe4ee85e96dd9e72df4a49a7242d1 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 28 Apr 2020 16:26:34 -0400 Subject: [PATCH 16/82] Fix reloading when using async --- {{cookiecutter.project_slug}}/compose/local/django/start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/compose/local/django/start b/{{cookiecutter.project_slug}}/compose/local/django/start index 9c0b43d1..660eda34 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/start +++ b/{{cookiecutter.project_slug}}/compose/local/django/start @@ -7,7 +7,7 @@ set -o nounset python manage.py migrate {%- if cookiecutter.use_async == 'y' %} -/usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:8000 --chdir=/app -k uvicorn.workers.UvicornWorker --reload +uvicorn config.asgi:application --host 0.0.0.0 --reload {%- else %} python manage.py runserver_plus 0.0.0.0:8000 {% endif %} From 672be773a376ce27a35b81573388e12c460af11a Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 28 Apr 2020 23:18:52 +0100 Subject: [PATCH 17/82] Fix formatting --- hooks/post_gen_project.py | 12 ++++++++++-- .../users/tests/test_drf_views.py | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 21d680e0..13d0ff00 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -299,8 +299,16 @@ def remove_aws_dockerfile(): def remove_drf_starter_files(): os.remove(os.path.join("config", "api_router.py")) shutil.rmtree(os.path.join("{{cookiecutter.project_slug}}", "users", "api")) - os.remove(os.path.join("{{cookiecutter.project_slug}}", "users", "tests", "test_drf_urls.py")) - os.remove(os.path.join("{{cookiecutter.project_slug}}", "users", "tests", "test_drf_views.py")) + os.remove( + os.path.join( + "{{cookiecutter.project_slug}}", "users", "tests", "test_drf_urls.py" + ) + ) + os.remove( + os.path.join( + "{{cookiecutter.project_slug}}", "users", "tests", "test_drf_views.py" + ) + ) def remove_storages_module(): diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py index 89c3c1a9..28f7526b 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py @@ -1,9 +1,9 @@ import pytest from django.test import RequestFactory -from {{ cookiecutter.project_slug }}.users.models import User -from {{ cookiecutter.project_slug }}.users.api.views import UserViewSet from {{ cookiecutter.project_slug }}.users.api.serializers import UserSerializer +from {{ cookiecutter.project_slug }}.users.api.views import UserViewSet +from {{ cookiecutter.project_slug }}.users.models import User pytestmark = pytest.mark.django_db From 5a9648fa90c10afb4a2a26b24bf82c0521ef680e Mon Sep 17 00:00:00 2001 From: Leon Kim Date: Wed, 29 Apr 2020 08:41:33 +0900 Subject: [PATCH 18/82] Update {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py OK. I agree with your idea. Even to me, this code is more explicit to check result. Co-Authored-By: Bruno Alla --- .../users/tests/test_drf_views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py index 28f7526b..9861af32 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py @@ -27,4 +27,9 @@ class TestUserViewSet: response = view.me(request) - assert response.data == UserSerializer(user, context={"request": request}).data + assert response.data == { + "username": user.username, + "email": user.email, + "name": user.name, + "url": f"/api/users/{user.username}/", + } From 29fea6efa375a7181ae3be3491e4b1db7a1d1219 Mon Sep 17 00:00:00 2001 From: Pilhwan Kim Date: Wed, 29 Apr 2020 08:54:32 +0900 Subject: [PATCH 19/82] remove import UserSerializer in tesf_drf_views.py --- .../users/tests/test_drf_views.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py index 9861af32..48147f87 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py @@ -1,7 +1,6 @@ import pytest from django.test import RequestFactory -from {{ cookiecutter.project_slug }}.users.api.serializers import UserSerializer from {{ cookiecutter.project_slug }}.users.api.views import UserViewSet from {{ cookiecutter.project_slug }}.users.models import User @@ -28,8 +27,8 @@ class TestUserViewSet: response = view.me(request) assert response.data == { - "username": user.username, - "email": user.email, - "name": user.name, + "username": user.username, + "email": user.email, + "name": user.name, "url": f"/api/users/{user.username}/", } From e46c9969ddabad3b6a4b184ecf4de7848849308a Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 29 Apr 2020 09:13:18 +0100 Subject: [PATCH 20/82] Run DRF tests on Travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b250148e..9abf37a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,8 @@ matrix: script: tox -e black-template - name: Basic Docker script: sh tests/test_docker.sh - - name: Docker with Celery - script: sh tests/test_docker.sh use_celery=y + - name: Extended Docker + script: sh tests/test_docker.sh use_celery=y use_drf=y - name: Bare metal script: sh tests/test_bare.sh use_celery=y use_compressor=y services: From d1c9791e9581baed2e918c140b177eb9991038d9 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 29 Apr 2020 09:17:19 +0100 Subject: [PATCH 21/82] Update CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 39e05c3f..81958bfd 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -161,6 +161,7 @@ Listed in alphabetical order. Krzysztof Żuraw `@krzysztofzuraw`_ Leo won `@leollon`_ Leo Zhou `@glasslion`_ + Leon Kim `@PilhwanKim`_ Leonardo Jimenez `@xpostudio4`_ Lin Xianyi `@iynaix`_ Luis Nell `@originell`_ @@ -365,6 +366,7 @@ Listed in alphabetical order. .. _@rjsnh1522: https://github.com/rjsnh1522 .. _@pchiquet: https://github.com/pchiquet .. _@phiberjenz: https://github.com/phiberjenz +.. _@PilhwanKim: https://github.com/PilhwanKim .. _@purplediane: https://github.com/purplediane .. _@raonyguimaraes: https://github.com/raonyguimaraes .. _@reggieriser: https://github.com/reggieriser From 01b84128057463999625631bd5d6874755db0f50 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 29 Apr 2020 09:23:27 +0100 Subject: [PATCH 22/82] Fix expected value --- .../{{cookiecutter.project_slug}}/users/tests/test_drf_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py index 48147f87..60944ad3 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_drf_views.py @@ -30,5 +30,5 @@ class TestUserViewSet: "username": user.username, "email": user.email, "name": user.name, - "url": f"/api/users/{user.username}/", + "url": f"http://testserver/api/users/{user.username}/", } From 47e82bd0849351b96f33f532b07a27a7d79f69ad Mon Sep 17 00:00:00 2001 From: browniebroke Date: Wed, 29 Apr 2020 12:00:30 +0100 Subject: [PATCH 23/82] Update uvicorn from 0.11.3 to 0.11.5 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index b9e26d39..c2d5babf 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -17,7 +17,7 @@ flower==0.9.4 # https://github.com/mher/flower {%- endif %} {%- endif %} {%- if cookiecutter.use_async == 'y' %} -uvicorn==0.11.3 # https://github.com/encode/uvicorn +uvicorn==0.11.5 # https://github.com/encode/uvicorn gunicorn==20.0.4 # https://github.com/benoitc/gunicorn {%- endif %} From d16d0aa5c4e67d439234a0e7d2e0ff57da3def98 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Wed, 29 Apr 2020 15:56:09 -0400 Subject: [PATCH 24/82] Add watchgod for uvicorn --- {{cookiecutter.project_slug}}/requirements/base.txt | 1 - {{cookiecutter.project_slug}}/requirements/local.txt | 3 +++ {{cookiecutter.project_slug}}/requirements/production.txt | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index c2d5babf..1f1450c4 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -18,7 +18,6 @@ flower==0.9.4 # https://github.com/mher/flower {%- endif %} {%- if cookiecutter.use_async == 'y' %} uvicorn==0.11.5 # https://github.com/encode/uvicorn -gunicorn==20.0.4 # https://github.com/benoitc/gunicorn {%- endif %} # Django diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index e3d013dc..9860c74b 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -8,6 +8,9 @@ psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} psycopg2-binary==2.8.5 # https://github.com/psycopg/psycopg2 {%- endif %} +{%- if cookiecutter.use_async == 'y' %} +watchgod==0.6 # https://github.com/samuelcolvin/watchgod +{%- endif %} # Testing # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index b45afb66..83ed366f 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -2,9 +2,7 @@ -r ./base.txt -{%- if cookiecutter.use_async == 'n' %} gunicorn==20.0.4 # https://github.com/benoitc/gunicorn -{%- endif %} psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- if cookiecutter.use_whitenoise == 'n' %} Collectfast==2.1.0 # https://github.com/antonagestam/collectfast From dfd1ee8bb2fd62fdf40fa60aa14821263bd98f94 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Wed, 29 Apr 2020 16:31:19 -0400 Subject: [PATCH 25/82] Use hiredis --- {{cookiecutter.project_slug}}/config/settings/production.py | 1 + {{cookiecutter.project_slug}}/requirements/base.txt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index c13f1aeb..6edc4ada 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -36,6 +36,7 @@ CACHES = { # Mimicing memcache behavior. # http://jazzband.github.io/django-redis/latest/#_memcached_exceptions_behavior "IGNORE_EXCEPTIONS": True, + "PARSER_CLASS": "redis.connection.HiredisParser", }, } } diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index c2d5babf..1783c8c1 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -8,7 +8,8 @@ argon2-cffi==19.2.0 # https://github.com/hynek/argon2_cffi {%- if cookiecutter.use_whitenoise == 'y' %} whitenoise==5.0.1 # https://github.com/evansd/whitenoise {%- endif %} -redis==3.4.1 # https://github.com/andymccurdy/redis-py +redis==3.4.1 # https://github.com/andymccurdy/redis-py +hiredis==1.0.1 # https://github.com/redis/hiredis-py {%- if cookiecutter.use_celery == "y" %} celery==4.4.2 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat From 4d54dcaa3218327b851dcbef03d50225dc3a4cf3 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Wed, 29 Apr 2020 16:42:24 -0400 Subject: [PATCH 26/82] Put hiredis in production only if using Win --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 ++ {{cookiecutter.project_slug}}/requirements/production.txt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 1783c8c1..0455e749 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -9,7 +9,9 @@ argon2-cffi==19.2.0 # https://github.com/hynek/argon2_cffi whitenoise==5.0.1 # https://github.com/evansd/whitenoise {%- endif %} redis==3.4.1 # https://github.com/andymccurdy/redis-py +{%- if cookiecutter.windows == "n" %} hiredis==1.0.1 # https://github.com/redis/hiredis-py +{%- endif %} {%- if cookiecutter.use_celery == "y" %} celery==4.4.2 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index b45afb66..51389345 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -12,6 +12,9 @@ Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- if cookiecutter.use_sentry == "y" %} sentry-sdk==0.14.3 # https://github.com/getsentry/sentry-python {%- endif %} +{%- if cookiecutter.windows == "y" %} +hiredis==1.0.1 # https://github.com/redis/hiredis-py +{%- endif %} # Django # ------------------------------------------------------------------------------ From f2a7c719e278c0ae0d8baeca64898595b2f72d6e Mon Sep 17 00:00:00 2001 From: browniebroke Date: Thu, 30 Apr 2020 12:00:30 +0100 Subject: [PATCH 27/82] Update redis from 3.4.1 to 3.5.0 --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index c2d5babf..4c1b55e1 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -8,7 +8,7 @@ argon2-cffi==19.2.0 # https://github.com/hynek/argon2_cffi {%- if cookiecutter.use_whitenoise == 'y' %} whitenoise==5.0.1 # https://github.com/evansd/whitenoise {%- endif %} -redis==3.4.1 # https://github.com/andymccurdy/redis-py +redis==3.5.0 # https://github.com/andymccurdy/redis-py {%- if cookiecutter.use_celery == "y" %} celery==4.4.2 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat From 1247f0639552355a17fb74c816adb4f754151932 Mon Sep 17 00:00:00 2001 From: "Fabio C. Barrionuevo da Luz" Date: Wed, 29 Apr 2020 19:07:21 -0300 Subject: [PATCH 28/82] Make sure to resolve symbolic links, uses an absolute path in ROOT_DIR and raise an error if the path does not exist by using the "resolve" method. Use "parent.parent.parent" instead of "parents[2]" --- {{cookiecutter.project_slug}}/config/asgi.py | 4 ++-- {{cookiecutter.project_slug}}/config/settings/base.py | 4 ++-- {{cookiecutter.project_slug}}/config/wsgi.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/asgi.py b/{{cookiecutter.project_slug}}/config/asgi.py index 562ecf40..8c99bbf5 100644 --- a/{{cookiecutter.project_slug}}/config/asgi.py +++ b/{{cookiecutter.project_slug}}/config/asgi.py @@ -15,8 +15,8 @@ from django.core.asgi import get_asgi_application # This allows easy placement of apps within the interior # {{ cookiecutter.project_slug }} directory. -app_path = Path(__file__).parents[1].resolve() -sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) +ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent +sys.path.append(str(ROOT_DIR / "{{ cookiecutter.project_slug }}")) # If DJANGO_SETTINGS_MODULE is unset, default to the local settings os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 390f2252..7f339fad 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -5,8 +5,8 @@ from pathlib import Path import environ -ROOT_DIR = Path(__file__).parents[2] -# {{ cookiecutter.project_slug }}/) +ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent +# {{ cookiecutter.project_slug }}/ APPS_DIR = ROOT_DIR / "{{ cookiecutter.project_slug }}" env = environ.Env() diff --git a/{{cookiecutter.project_slug}}/config/wsgi.py b/{{cookiecutter.project_slug}}/config/wsgi.py index fccfea35..a7de581c 100644 --- a/{{cookiecutter.project_slug}}/config/wsgi.py +++ b/{{cookiecutter.project_slug}}/config/wsgi.py @@ -21,8 +21,8 @@ from django.core.wsgi import get_wsgi_application # This allows easy placement of apps within the interior # {{ cookiecutter.project_slug }} directory. -app_path = Path(__file__).parents[1].resolve() -sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) +ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent +sys.path.append(str(ROOT_DIR / "{{ cookiecutter.project_slug }}")) # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks # if running multiple sites in the same mod_wsgi process. To fix this, use # mod_wsgi daemon mode with each site in its own daemon process, or use From bf5f557d2b1f3e9ff784e2aae3b357a34df3e722 Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Fri, 1 May 2020 10:35:20 -0400 Subject: [PATCH 29/82] Added docker parameter to hiredis requirement --- {{cookiecutter.project_slug}}/config/settings/production.py | 1 - {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 6edc4ada..c13f1aeb 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -36,7 +36,6 @@ CACHES = { # Mimicing memcache behavior. # http://jazzband.github.io/django-redis/latest/#_memcached_exceptions_behavior "IGNORE_EXCEPTIONS": True, - "PARSER_CLASS": "redis.connection.HiredisParser", }, } } diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 0455e749..7fa0aeca 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -9,7 +9,7 @@ argon2-cffi==19.2.0 # https://github.com/hynek/argon2_cffi whitenoise==5.0.1 # https://github.com/evansd/whitenoise {%- endif %} redis==3.4.1 # https://github.com/andymccurdy/redis-py -{%- if cookiecutter.windows == "n" %} +{%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "n" %} hiredis==1.0.1 # https://github.com/redis/hiredis-py {%- endif %} {%- if cookiecutter.use_celery == "y" %} diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 51389345..4f0e6119 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -12,7 +12,7 @@ Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- if cookiecutter.use_sentry == "y" %} sentry-sdk==0.14.3 # https://github.com/getsentry/sentry-python {%- endif %} -{%- if cookiecutter.windows == "y" %} +{%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "y" %} hiredis==1.0.1 # https://github.com/redis/hiredis-py {%- endif %} From b70b6ebd7e99e8bba88fddd29653f501c513ea2b Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Fri, 1 May 2020 10:39:30 -0400 Subject: [PATCH 30/82] Fixed production.txt typo when docker and windows combine --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 4f0e6119..c5ba356c 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -12,7 +12,7 @@ Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- if cookiecutter.use_sentry == "y" %} sentry-sdk==0.14.3 # https://github.com/getsentry/sentry-python {%- endif %} -{%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "y" %} +{%- if cookiecutter.use_docker == "n" and cookiecutter.windows == "y" %} hiredis==1.0.1 # https://github.com/redis/hiredis-py {%- endif %} From bcfcd384f823a7363c47988444342f95bcc895c9 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 17 Mar 2020 18:58:11 +0000 Subject: [PATCH 31/82] Test user detail view --- .../users/tests/test_views.py | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py index ca006059..82abecb5 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py @@ -1,8 +1,15 @@ import pytest +from django.contrib.auth.models import AnonymousUser +from django.http.response import Http404 from django.test import RequestFactory from {{ cookiecutter.project_slug }}.users.models import User -from {{ cookiecutter.project_slug }}.users.views import UserRedirectView, UserUpdateView +from {{ cookiecutter.project_slug }}.users.tests.factories import UserFactory +from {{ cookiecutter.project_slug }}.users.views import ( + UserRedirectView, + UserUpdateView, + user_detail_view, +) pytestmark = pytest.mark.django_db @@ -44,3 +51,29 @@ class TestUserRedirectView: view.request = request assert view.get_redirect_url() == f"/users/{user.username}/" + + +class TestUserDetailView: + def test_authenticated(self, user: User, rf: RequestFactory): + request = rf.get("/fake-url/") + request.user = UserFactory() + + response = user_detail_view(request, username=user.username) + + assert response.status_code == 200 + + def test_not_authenticated(self, user: User, rf: RequestFactory): + request = rf.get("/fake-url/") + request.user = AnonymousUser() # type: ignore + + response = user_detail_view(request, username=user.username) + + assert response.status_code == 302 + assert response.url == f"/accounts/login/?next=/fake-url/" + + def test_case_sensitivity(self, rf: RequestFactory): + request = rf.get("/fake-url/") + request.user = UserFactory(username="UserName") + + with pytest.raises(Http404): + user_detail_view(request, username="username") From 05a5bbbad73cf37ba7527e2efd6283697a733145 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 1 May 2020 17:57:43 +0100 Subject: [PATCH 32/82] Use default distribution on Travis --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9abf37a1..6039075a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -dist: xenial - services: - docker From e37627c4b1d74deed8a422098d3a3c0de9de8c8a Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 1 May 2020 19:10:42 +0100 Subject: [PATCH 33/82] Fix pre-commit config & add Black to the pre-commmit hooks Fixes #2502 --- .../.pre-commit-config.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index c50fefe9..60f46363 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -3,18 +3,22 @@ default_stages: [commit] fail_fast: true repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: master hooks: - id: trailing-whitespace - files: (^|/).+\.(py|html|sh|css|js)$ + - id: end-of-file-fixer + - id: check-yaml -- repo: local + - repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.9 hooks: - id: flake8 - name: flake8 - entry: flake8 - language: python - types: [python] args: ['--config=setup.cfg'] + additional_dependencies: [flake8-isort] From 3f0ff8aae9b15b38d2480e7f3ac43b0ed0380797 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sat, 2 May 2020 22:30:22 -0700 Subject: [PATCH 34/82] Update tox from 3.14.6 to 3.15.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 18439a35..a4465791 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ flake8-isort==3.0.0 # Testing # ------------------------------------------------------------------------------ -tox==3.14.6 +tox==3.15.0 pytest==5.4.1 pytest-cookies==0.5.1 pytest-instafail==0.4.1.post0 From 79f6fdbee32549fd77168769c374ffdc0ff5edc0 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sat, 9 May 2020 00:17:29 -0700 Subject: [PATCH 35/82] Update pytest from 5.4.1 to 5.4.2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a4465791..12f3d898 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ flake8-isort==3.0.0 # Testing # ------------------------------------------------------------------------------ tox==3.15.0 -pytest==5.4.1 +pytest==5.4.2 pytest-cookies==0.5.1 pytest-instafail==0.4.1.post0 pyyaml==5.3.1 From 580ef4117d148f678acb294b29503c3edca4a307 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sat, 9 May 2020 00:17:30 -0700 Subject: [PATCH 36/82] Update pytest from 5.4.1 to 5.4.2 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 9860c74b..79c5523d 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -16,7 +16,7 @@ watchgod==0.6 # https://github.com/samuelcolvin/watchgod # ------------------------------------------------------------------------------ mypy==0.770 # https://github.com/python/mypy django-stubs==1.5.0 # https://github.com/typeddjango/django-stubs -pytest==5.4.1 # https://github.com/pytest-dev/pytest +pytest==5.4.2 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar # Code quality From a5cb77399ef3e609739494301f25a77a27c98fa3 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 11 May 2020 14:13:47 -0700 Subject: [PATCH 37/82] Update pre-commit from 2.3.0 to 2.4.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 79c5523d..91cde609 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -29,7 +29,7 @@ pylint-django==2.0.15 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery {%- endif %} -pre-commit==2.3.0 # https://github.com/pre-commit/pre-commit +pre-commit==2.4.0 # https://github.com/pre-commit/pre-commit # Django # ------------------------------------------------------------------------------ From 7b1365c564639f9983e91f5f5a752fb5db18d15c Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 12 May 2020 01:06:19 -0700 Subject: [PATCH 38/82] Update flake8 from 3.7.9 to 3.8.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 12f3d898..e109518e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ binaryornot==0.4.4 # Code quality # ------------------------------------------------------------------------------ black==19.10b0 -flake8==3.7.9 +flake8==3.8.1 flake8-isort==3.0.0 # Testing From b1c6ad25d21c9969c665a5a76cd47c2a24e40cb2 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 12 May 2020 01:06:20 -0700 Subject: [PATCH 39/82] Update flake8 from 3.7.9 to 3.8.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 79c5523d..d4e065ff 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -21,7 +21,7 @@ pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar # Code quality # ------------------------------------------------------------------------------ -flake8==3.7.9 # https://github.com/PyCQA/flake8 +flake8==3.8.1 # https://github.com/PyCQA/flake8 flake8-isort==3.0.0 # https://github.com/gforcada/flake8-isort coverage==5.1 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black From cd740c26194d4418026dcc05fb56e2c6ccb0711b Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 12 May 2020 10:12:48 +0100 Subject: [PATCH 40/82] Update flake8 from 3.7.9 to 3.8.1 in pre-commit config --- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 60f46363..71524052 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.7.9 + rev: 3.8.1 hooks: - id: flake8 args: ['--config=setup.cfg'] From 81642420c4da18fabd6cc8e9c5e3365a57e6afba Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 12 May 2020 10:14:34 +0100 Subject: [PATCH 41/82] Run flake8 from the generated project root 3.8.1 can't find the config if running from elsewhere: https://gitlab.com/pycqa/flake8/-/issues/639 --- tests/test_cookiecutter_generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 51500705..664158b5 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -156,7 +156,7 @@ def test_flake8_passes(cookies, context_override): result = cookies.bake(extra_context=context_override) try: - sh.flake8(str(result.project)) + sh.flake8(_cwd=str(result.project)) except sh.ErrorReturnCode as e: pytest.fail(e.stdout.decode()) @@ -167,7 +167,7 @@ def test_black_passes(cookies, context_override): result = cookies.bake(extra_context=context_override) try: - sh.black("--check", "--diff", "--exclude", "migrations", f"{result.project}/") + sh.black("--check", "--diff", "--exclude", "migrations", _cwd=str(result.project)) except sh.ErrorReturnCode as e: pytest.fail(e.stdout.decode()) From 09790ee8fb73d56662c1367f53132e08452d6614 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 12 May 2020 10:18:15 +0100 Subject: [PATCH 42/82] Resolve new flake8 error --- .../{{cookiecutter.project_slug}}/users/tests/test_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py index 82abecb5..18b8da7a 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/tests/test_views.py @@ -69,7 +69,7 @@ class TestUserDetailView: response = user_detail_view(request, username=user.username) assert response.status_code == 302 - assert response.url == f"/accounts/login/?next=/fake-url/" + assert response.url == "/accounts/login/?next=/fake-url/" def test_case_sensitivity(self, rf: RequestFactory): request = rf.get("/fake-url/") From 6f88fe6b4fa8b173ab63115387cdd7b1fa516127 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 12 May 2020 10:24:25 +0100 Subject: [PATCH 43/82] Reformat test file --- tests/test_cookiecutter_generation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 664158b5..aa7cc75a 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -167,7 +167,9 @@ def test_black_passes(cookies, context_override): result = cookies.bake(extra_context=context_override) try: - sh.black("--check", "--diff", "--exclude", "migrations", _cwd=str(result.project)) + sh.black( + "--check", "--diff", "--exclude", "migrations", _cwd=str(result.project) + ) except sh.ErrorReturnCode as e: pytest.fail(e.stdout.decode()) From 309376ee4491134b0706cedc4ca567aa20f7229e Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 12 May 2020 19:50:12 +0100 Subject: [PATCH 44/82] Remove manual requirements Issue with PyUP seems fixed --- .pyup.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.pyup.yml b/.pyup.yml index c503dabf..bffaa06c 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -12,11 +12,3 @@ pin: True # requires private repo permissions, even on public repos # default: empty label_prs: update - -# Specify requirement files by hand, pyup seems to struggle to -# find the ones in the project_slug folder -requirements: - - "requirements.txt" - - "{{cookiecutter.project_slug}}/requirements/base.txt" - - "{{cookiecutter.project_slug}}/requirements/local.txt" - - "{{cookiecutter.project_slug}}/requirements/production.txt" From ce66080f857ef9e19067c30898d88e85940a3ce1 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 13 May 2020 12:42:53 -0700 Subject: [PATCH 45/82] Update sentry-sdk from 0.14.3 to 0.14.4 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index edf9a590..2b8ac9f8 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -8,7 +8,7 @@ psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- endif %} {%- if cookiecutter.use_sentry == "y" %} -sentry-sdk==0.14.3 # https://github.com/getsentry/sentry-python +sentry-sdk==0.14.4 # https://github.com/getsentry/sentry-python {%- endif %} {%- if cookiecutter.use_docker == "n" and cookiecutter.windows == "y" %} hiredis==1.0.1 # https://github.com/redis/hiredis-py From 70f6471c751b2eab63b3f343c87ebb60b0b3d0ca Mon Sep 17 00:00:00 2001 From: Tano Abeleyra Date: Sun, 17 May 2020 12:37:35 -0300 Subject: [PATCH 46/82] Allow to use a CDN with S3 --- .../config/settings/production.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index c13f1aeb..3d4f324c 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -90,6 +90,9 @@ AWS_S3_OBJECT_PARAMETERS = { AWS_DEFAULT_ACL = None # https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None) +# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#cloudfront +AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None) +aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com" {% elif cookiecutter.cloud_provider == 'GCP' %} GS_BUCKET_NAME = env("DJANGO_GCP_STORAGE_BUCKET_NAME") GS_DEFAULT_ACL = "publicRead" @@ -104,7 +107,7 @@ STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" {% elif cookiecutter.cloud_provider == 'AWS' -%} STATICFILES_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.StaticRootS3Boto3Storage" COLLECTFAST_STRATEGY = "collectfast.strategies.boto3.Boto3Strategy" -STATIC_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/static/" +STATIC_URL = f"https://{aws_s3_domain}/static/" {% elif cookiecutter.cloud_provider == 'GCP' -%} STATICFILES_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.StaticRootGoogleCloudStorage" COLLECTFAST_STRATEGY = "collectfast.strategies.gcloud.GoogleCloudStrategy" @@ -115,7 +118,7 @@ STATIC_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/static/" # ------------------------------------------------------------------------------ {%- if cookiecutter.cloud_provider == 'AWS' %} DEFAULT_FILE_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.MediaRootS3Boto3Storage" -MEDIA_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/media/" +MEDIA_URL = f"https://{aws_s3_domain}/media/" {%- elif cookiecutter.cloud_provider == 'GCP' %} DEFAULT_FILE_STORAGE = "{{cookiecutter.project_slug}}.utils.storages.MediaRootGoogleCloudStorage" MEDIA_URL = f"https://storage.googleapis.com/{GS_BUCKET_NAME}/media/" From 15fa899bb442da2298cdb67514da78803d2d54c6 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 20 May 2020 19:23:53 -0700 Subject: [PATCH 47/82] Update tox from 3.15.0 to 3.15.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e109518e..02548be7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ flake8-isort==3.0.0 # Testing # ------------------------------------------------------------------------------ -tox==3.15.0 +tox==3.15.1 pytest==5.4.2 pytest-cookies==0.5.1 pytest-instafail==0.4.1.post0 From a8672e08cb8e0a8942c18fed0ae331a77e879c03 Mon Sep 17 00:00:00 2001 From: "pyup.io bot" Date: Sun, 24 May 2020 03:02:08 +0200 Subject: [PATCH 48/82] Update flake8 to 3.8.2 (#2607) --- requirements.txt | 2 +- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 02548be7..067ad6c6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ binaryornot==0.4.4 # Code quality # ------------------------------------------------------------------------------ black==19.10b0 -flake8==3.8.1 +flake8==3.8.2 flake8-isort==3.0.0 # Testing diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 6f7fa2de..78a1f6c3 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -21,7 +21,7 @@ pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar # Code quality # ------------------------------------------------------------------------------ -flake8==3.8.1 # https://github.com/PyCQA/flake8 +flake8==3.8.2 # https://github.com/PyCQA/flake8 flake8-isort==3.0.0 # https://github.com/gforcada/flake8-isort coverage==5.1 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black From 286363799cfa1087b02570f6fb6ffd079b8daf36 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Tue, 26 May 2020 01:25:38 +0300 Subject: [PATCH 49/82] :pencil: added websockets doc page #2506 * Simple explanation. * Example of usage with JS. * Additional nGinx config example. --- docs/index.rst | 1 + docs/websocket.rst | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 docs/websocket.rst diff --git a/docs/index.rst b/docs/index.rst index b29e728e..f6218464 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,6 +23,7 @@ Contents: deployment-on-heroku deployment-with-docker docker-postgres-backups + websocket faq troubleshooting diff --git a/docs/websocket.rst b/docs/websocket.rst new file mode 100644 index 00000000..a880f569 --- /dev/null +++ b/docs/websocket.rst @@ -0,0 +1,32 @@ +.. _websocket: + +========= +Websocket +========= + +You can enable web sockets if you select ``use_async`` option when creating a project. That indicates whether the project should use web sockets with Uvicorn + Gunicorn. + +Usage +----- + +JavaScript example: :: + + > ws = new WebSocket('ws://localhost:8000/') // or 'wss:///' in prod + WebSocket {url: "ws://localhost:8000/", readyState: 0, bufferedAmount: 0, onopen: null, onerror: null, …} + > ws.onmessage = event => console.log(event.data) + event => console.log(event.data) + > ws.send("ping") + undefined + pong! + +If you are using nGinx instead of Traefik, you should add these lines to nGinx config: :: + + location /websocket/ { + proxy_pass http://backend; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_read_timeout 86400; + } + +Source: https://www.nginx.com/blog/websocket-nginx/ From 090c62e862f61083d0cf397bf7666773ecdfd273 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 27 May 2020 02:27:13 -0700 Subject: [PATCH 50/82] Update sphinx from 3.0.3 to 3.0.4 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 78a1f6c3..d38a70bc 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.1 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb -Sphinx==3.0.3 # https://github.com/sphinx-doc/sphinx +Sphinx==3.0.4 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From 009ca15a4c797c53dfeeff40a6620c5732a59ee3 Mon Sep 17 00:00:00 2001 From: Tano Abeleyra Date: Thu, 28 May 2020 19:16:54 -0300 Subject: [PATCH 51/82] Add AWS_S3_CUSTOM_DOMAIN entry to settings.rst --- docs/settings.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/settings.rst b/docs/settings.rst index 2ae8814e..949d5f35 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -45,6 +45,7 @@ DJANGO_AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_ID n/a DJANGO_AWS_SECRET_ACCESS_KEY AWS_SECRET_ACCESS_KEY n/a raises error DJANGO_AWS_STORAGE_BUCKET_NAME AWS_STORAGE_BUCKET_NAME n/a raises error DJANGO_AWS_S3_REGION_NAME AWS_S3_REGION_NAME n/a None +DJANGO_AWS_S3_CUSTOM_DOMAIN AWS_S3_CUSTOM_DOMAIN n/a None DJANGO_GCP_STORAGE_BUCKET_NAME GS_BUCKET_NAME n/a raises error GOOGLE_APPLICATION_CREDENTIALS n/a n/a raises error SENTRY_DSN SENTRY_DSN n/a raises error From 7c3558fa624d3069007df3e1071bcbd93be6d6c9 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Fri, 29 May 2020 17:23:15 -0400 Subject: [PATCH 52/82] Fix Docker configuration for Gitlab CI #2549 * Just missing the services I believe according to @rocode? * I'm hoping to just completely eradicate the need for this setup with a follow-up PR for completely non-Docker approach on CI that supports celery, too. --- {{cookiecutter.project_slug}}/.gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index a74d5de8..f7c4f24a 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -23,6 +23,7 @@ pytest: stage: test image: python:3.7 {% if cookiecutter.use_docker == 'y' -%} + image: docker/compose:latest tags: - docker services: From d7f22a1158839d27ff898ae66f8edf39ac1943a6 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Fri, 29 May 2020 18:05:44 -0400 Subject: [PATCH 53/82] Changed service to Docker dind --- {{cookiecutter.project_slug}}/.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index f7c4f24a..246c4c98 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -27,7 +27,7 @@ pytest: tags: - docker services: - - docker + - docker:dind before_script: - docker-compose -f local.yml build # Ensure celerybeat does not crash due to non-existent tables From 433d30ec1437e282541912e111f68e92e51ea2d0 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 3 Jun 2020 00:26:12 -0700 Subject: [PATCH 54/82] Update pytest from 5.4.2 to 5.4.3 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 067ad6c6..80882d4c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ flake8-isort==3.0.0 # Testing # ------------------------------------------------------------------------------ tox==3.15.1 -pytest==5.4.2 +pytest==5.4.3 pytest-cookies==0.5.1 pytest-instafail==0.4.1.post0 pyyaml==5.3.1 From 9e87d4b189fb9b7c414a7113ecf02612962f6d73 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 3 Jun 2020 00:26:13 -0700 Subject: [PATCH 55/82] Update pytest from 5.4.2 to 5.4.3 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index d38a70bc..b5d9a250 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -16,7 +16,7 @@ watchgod==0.6 # https://github.com/samuelcolvin/watchgod # ------------------------------------------------------------------------------ mypy==0.770 # https://github.com/python/mypy django-stubs==1.5.0 # https://github.com/typeddjango/django-stubs -pytest==5.4.2 # https://github.com/pytest-dev/pytest +pytest==5.4.3 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar # Code quality From 9d0b570c51986ea9586240c24c2ceaf52feec25a Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Wed, 3 Jun 2020 05:12:36 -0700 Subject: [PATCH 56/82] Update mypy from 0.770 to 0.780 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index d38a70bc..3c30b154 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -14,7 +14,7 @@ watchgod==0.6 # https://github.com/samuelcolvin/watchgod # Testing # ------------------------------------------------------------------------------ -mypy==0.770 # https://github.com/python/mypy +mypy==0.780 # https://github.com/python/mypy django-stubs==1.5.0 # https://github.com/typeddjango/django-stubs pytest==5.4.2 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar From 24e8a17d74a47e57dfc05a754be76a566ef504df Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Fri, 5 Jun 2020 17:08:27 -0700 Subject: [PATCH 57/82] Update collectfast from 2.1.0 to 2.2.0 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 2b8ac9f8..a614bdbe 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -5,7 +5,7 @@ gunicorn==20.0.4 # https://github.com/benoitc/gunicorn psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- if cookiecutter.use_whitenoise == 'n' %} -Collectfast==2.1.0 # https://github.com/antonagestam/collectfast +Collectfast==2.2.0 # https://github.com/antonagestam/collectfast {%- endif %} {%- if cookiecutter.use_sentry == "y" %} sentry-sdk==0.14.4 # https://github.com/getsentry/sentry-python From 52c4f57ecab2c10c0f5f4039b088d946df85295a Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sun, 7 Jun 2020 14:24:38 -0700 Subject: [PATCH 58/82] Update tox from 3.15.1 to 3.15.2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 80882d4c..d05ed6a4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ flake8-isort==3.0.0 # Testing # ------------------------------------------------------------------------------ -tox==3.15.1 +tox==3.15.2 pytest==5.4.3 pytest-cookies==0.5.1 pytest-instafail==0.4.1.post0 From afe02f2fd19aa1df15309aaf9641d38b8783f270 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 8 Jun 2020 17:02:41 -0700 Subject: [PATCH 59/82] Update flake8 from 3.8.2 to 3.8.3 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 80882d4c..4044d304 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ binaryornot==0.4.4 # Code quality # ------------------------------------------------------------------------------ black==19.10b0 -flake8==3.8.2 +flake8==3.8.3 flake8-isort==3.0.0 # Testing From 6038a654abdecbaf091298bdf69e628e23132b9b Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 8 Jun 2020 17:02:43 -0700 Subject: [PATCH 60/82] Update flake8 from 3.8.2 to 3.8.3 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index b5d9a250..e02bb456 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -21,7 +21,7 @@ pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar # Code quality # ------------------------------------------------------------------------------ -flake8==3.8.2 # https://github.com/PyCQA/flake8 +flake8==3.8.3 # https://github.com/PyCQA/flake8 flake8-isort==3.0.0 # https://github.com/gforcada/flake8-isort coverage==5.1 # https://github.com/nedbat/coveragepy black==19.10b0 # https://github.com/ambv/black From 54f8e3d672671434dd68629e96ace6108f6fbd7a Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 9 Jun 2020 16:02:00 -0700 Subject: [PATCH 61/82] Update pre-commit from 2.4.0 to 2.5.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index b5d9a250..4986bdaf 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -29,7 +29,7 @@ pylint-django==2.0.15 # https://github.com/PyCQA/pylint-django {%- if cookiecutter.use_celery == 'y' %} pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery {%- endif %} -pre-commit==2.4.0 # https://github.com/pre-commit/pre-commit +pre-commit==2.5.1 # https://github.com/pre-commit/pre-commit # Django # ------------------------------------------------------------------------------ From b7c75bccf51b19a4fd8f156f104e0f36619e8235 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sun, 14 Jun 2020 03:12:50 -0700 Subject: [PATCH 62/82] Update pytest-instafail from 0.4.1.post0 to 0.4.2 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 80882d4c..e7fbe1d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,5 +13,5 @@ flake8-isort==3.0.0 tox==3.15.1 pytest==5.4.3 pytest-cookies==0.5.1 -pytest-instafail==0.4.1.post0 +pytest-instafail==0.4.2 pyyaml==5.3.1 From 1b6e4994ca45ef38551a4cf2573c9241e821dce6 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sun, 14 Jun 2020 03:13:04 -0700 Subject: [PATCH 63/82] Update sphinx from 3.0.4 to 3.1.1 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index b5d9a250..e661835d 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -2,7 +2,7 @@ Werkzeug==1.0.1 # https://github.com/pallets/werkzeug ipdb==0.13.2 # https://github.com/gotcha/ipdb -Sphinx==3.0.4 # https://github.com/sphinx-doc/sphinx +Sphinx==3.1.1 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 {%- else %} From 89b81452a9201fbed87598e2567ba8d629e97f2a Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 16 Jun 2020 20:21:51 -0400 Subject: [PATCH 64/82] Update Django to 3.0.7 due to CVEs There were several CVE's that arose between 3.0.3 to 3.0.7. Updating quickly will resolve the vulnerabilities and fix several PRs. --- {{cookiecutter.project_slug}}/requirements/base.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 4f2ebe49..e1c7d9ef 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -25,7 +25,7 @@ uvicorn==0.11.5 # https://github.com/encode/uvicorn # Django # ------------------------------------------------------------------------------ -django==3.0.5 # pyup: < 3.1 # https://www.djangoproject.com/ +django==3.0.7 # pyup: < 3.1 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==4.0.0 # https://github.com/jazzband/django-model-utils django-allauth==0.41.0 # https://github.com/pennersr/django-allauth From 8bdef165a893cff627a6876be887756ee13be6c7 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 16 Jun 2020 23:51:21 -0400 Subject: [PATCH 65/82] Fixed local async command in docs --- docs/developing-locally.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index dc146c23..a5d598f0 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -80,7 +80,7 @@ First things first. or if you're running asynchronously: :: - $ gunicorn config.asgi --bind 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker --reload + $ uvicorn config.asgi:application --host 0.0.0.0 --reload .. _PostgreSQL: https://www.postgresql.org/download/ .. _Redis: https://redis.io/download From 4b103d1d93ab6dabf93813d270656da33d128699 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 17 Jun 2020 23:15:32 +0100 Subject: [PATCH 66/82] Update .pyup.yml --- .pyup.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pyup.yml b/.pyup.yml index bffaa06c..4082eed8 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -12,3 +12,9 @@ pin: True # requires private repo permissions, even on public repos # default: empty label_prs: update + +requirements: + - requirements.txt + - {{cookiecutter.project_slug}}/requirements/base.txt + - {{cookiecutter.project_slug}}/requirements/local.txt + - {{cookiecutter.project_slug}}/requirements/production.txt From d2e9e8ee3f24fd6c6064ebdac8415b4ae9474ab1 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Wed, 17 Jun 2020 23:16:13 +0100 Subject: [PATCH 67/82] Update .pyup.yml --- .pyup.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pyup.yml b/.pyup.yml index 4082eed8..b330b22b 100644 --- a/.pyup.yml +++ b/.pyup.yml @@ -14,7 +14,7 @@ pin: True label_prs: update requirements: - - requirements.txt - - {{cookiecutter.project_slug}}/requirements/base.txt - - {{cookiecutter.project_slug}}/requirements/local.txt - - {{cookiecutter.project_slug}}/requirements/production.txt + - "requirements.txt" + - "{{cookiecutter.project_slug}}/requirements/base.txt" + - "{{cookiecutter.project_slug}}/requirements/local.txt" + - "{{cookiecutter.project_slug}}/requirements/production.txt" From d3a000d76d233debb975e570f5093a2cb4e9bdb0 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Thu, 18 Jun 2020 04:45:15 -0700 Subject: [PATCH 68/82] Update sentry-sdk from 0.14.4 to 0.15.1 --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 2b8ac9f8..eda39264 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -8,7 +8,7 @@ psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 Collectfast==2.1.0 # https://github.com/antonagestam/collectfast {%- endif %} {%- if cookiecutter.use_sentry == "y" %} -sentry-sdk==0.14.4 # https://github.com/getsentry/sentry-python +sentry-sdk==0.15.1 # https://github.com/getsentry/sentry-python {%- endif %} {%- if cookiecutter.use_docker == "n" and cookiecutter.windows == "y" %} hiredis==1.0.1 # https://github.com/redis/hiredis-py From d979c342d655a537b9f131c9cf0ae8a9ed0f30cf Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sat, 20 Jun 2020 08:51:49 -0700 Subject: [PATCH 69/82] Update mypy from 0.780 to 0.781 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index fdd9fd44..9e2be82b 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -14,7 +14,7 @@ watchgod==0.6 # https://github.com/samuelcolvin/watchgod # Testing # ------------------------------------------------------------------------------ -mypy==0.780 # https://github.com/python/mypy +mypy==0.781 # https://github.com/python/mypy django-stubs==1.5.0 # https://github.com/typeddjango/django-stubs pytest==5.4.3 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar From 88f9a6c289ccb9e30ff991fd5788b7b215763a20 Mon Sep 17 00:00:00 2001 From: Gil Date: Sun, 21 Jun 2020 16:13:42 +0900 Subject: [PATCH 70/82] Replace User by get_user_model --- .../{{cookiecutter.project_slug}}/users/api/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/serializers.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/serializers.py index 04bf4c85..8bd39d30 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/serializers.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/api/serializers.py @@ -1,6 +1,7 @@ +from django.contrib.auth import get_user_model from rest_framework import serializers -from {{ cookiecutter.project_slug }}.users.models import User +User = get_user_model() class UserSerializer(serializers.ModelSerializer): From 3961ab8dd83e2b5bd71bccee00212a731e4babfd Mon Sep 17 00:00:00 2001 From: Gil Date: Sun, 21 Jun 2020 16:17:26 +0900 Subject: [PATCH 71/82] Add AsheKR in CONTRIBUTORS.rst --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 5962af75..c1813e83 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -65,6 +65,7 @@ Listed in alphabetical order. Anuj Bansal `@ahhda`_ Arcuri Davide `@dadokkio`_ Areski Belaid `@areski`_ + AsheKR `@ashekr`_ Ashley Camba Barclay Gauld `@yunti`_ Bartek `@btknu`_ From f4aee2bc68af593bd4239ae0272899efadb0f5f5 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 21 Jun 2020 14:15:00 +0100 Subject: [PATCH 72/82] Fix broken link --- CONTRIBUTORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index c1813e83..32ba496e 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -252,6 +252,7 @@ Listed in alphabetical order. .. _@archinal: https://github.com/archinal .. _@areski: https://github.com/areski .. _@arruda: https://github.com/arruda +.. _@ashekr: https://github.com/ashekr .. _@bertdemiranda: https://github.com/bertdemiranda .. _@bittner: https://github.com/bittner .. _@blaxpy: https://github.com/blaxpy From 793151162770d8a4538627af6638253af7d95e98 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 21 Jun 2020 14:20:29 +0100 Subject: [PATCH 73/82] Bump version to 3.0.7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6dfd9e50..6b80bd9a 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ except ImportError: # Our version ALWAYS matches the version of Django we support # If Django has a new release, we branch, tag, then update this setting after the tag. -version = "3.0.5-01" +version = "3.0.7" if sys.argv[-1] == "tag": os.system(f'git tag -a {version} -m "version {version}"') From fe8a939611f123ece8a36410d5ae3c1f4b6822da Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 21 Jun 2020 14:23:48 +0100 Subject: [PATCH 74/82] Bump flake8 in pre-commit config --- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 71524052..6aa9207a 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.1 + rev: 3.8.3 hooks: - id: flake8 args: ['--config=setup.cfg'] From aadf66185cadaf5c5388b6e7ab9754379b1aad48 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 21 Jun 2020 14:26:40 +0100 Subject: [PATCH 75/82] Update base requirements to latest version --- {{cookiecutter.project_slug}}/requirements/base.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index e1c7d9ef..4baf2f37 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -4,16 +4,16 @@ Pillow==7.1.2 # https://github.com/python-pillow/Pillow {%- if cookiecutter.use_compressor == "y" %} rcssmin==1.0.6{% if cookiecutter.windows == 'y' and cookiecutter.use_docker == 'n' %} --install-option="--without-c-extensions"{% endif %} # https://github.com/ndparker/rcssmin {%- endif %} -argon2-cffi==19.2.0 # https://github.com/hynek/argon2_cffi +argon2-cffi==20.1.0 # https://github.com/hynek/argon2_cffi {%- if cookiecutter.use_whitenoise == 'y' %} -whitenoise==5.0.1 # https://github.com/evansd/whitenoise +whitenoise==5.1.0 # https://github.com/evansd/whitenoise {%- endif %} redis==3.5.0 # https://github.com/andymccurdy/redis-py {%- if cookiecutter.use_docker == "y" or cookiecutter.windows == "n" %} hiredis==1.0.1 # https://github.com/redis/hiredis-py {%- endif %} {%- if cookiecutter.use_celery == "y" %} -celery==4.4.2 # pyup: < 5.0 # https://github.com/celery/celery +celery==4.4.5 # pyup: < 5.0 # https://github.com/celery/celery django-celery-beat==2.0.0 # https://github.com/celery/django-celery-beat {%- if cookiecutter.use_docker == 'y' %} flower==0.9.4 # https://github.com/mher/flower @@ -28,12 +28,12 @@ uvicorn==0.11.5 # https://github.com/encode/uvicorn django==3.0.7 # pyup: < 3.1 # https://www.djangoproject.com/ django-environ==0.4.5 # https://github.com/joke2k/django-environ django-model-utils==4.0.0 # https://github.com/jazzband/django-model-utils -django-allauth==0.41.0 # https://github.com/pennersr/django-allauth -django-crispy-forms==1.9.0 # https://github.com/django-crispy-forms/django-crispy-forms +django-allauth==0.42.0 # https://github.com/pennersr/django-allauth +django-crispy-forms==1.9.1 # https://github.com/django-crispy-forms/django-crispy-forms {%- if cookiecutter.use_compressor == "y" %} django-compressor==2.4 # https://github.com/django-compressor/django-compressor {%- endif %} -django-redis==4.11.0 # https://github.com/jazzband/django-redis +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 From e4a4d900688fe389eb45d40ed7d8b7808a7a5125 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 21 Jun 2020 14:48:28 +0100 Subject: [PATCH 76/82] Add badge for documentation build status --- README.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.rst b/README.rst index 02f220cf..cfb25378 100644 --- a/README.rst +++ b/README.rst @@ -5,6 +5,10 @@ Cookiecutter Django :target: https://travis-ci.org/pydanny/cookiecutter-django?branch=master :alt: Build Status +.. image:: https://readthedocs.org/projects/cookiecutter-django/badge/?version=latest + :target: https://cookiecutter-django.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + .. image:: https://pyup.io/repos/github/pydanny/cookiecutter-django/shield.svg :target: https://pyup.io/repos/github/pydanny/cookiecutter-django/ :alt: Updates From 7ba61274cefdaf295fc2d1cd863dab9c6b8644b8 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Mon, 22 Jun 2020 21:42:39 +0300 Subject: [PATCH 77/82] :pencil: docs updated after review --- docs/websocket.rst | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/docs/websocket.rst b/docs/websocket.rst index a880f569..9d2e3264 100644 --- a/docs/websocket.rst +++ b/docs/websocket.rst @@ -4,7 +4,7 @@ Websocket ========= -You can enable web sockets if you select ``use_async`` option when creating a project. That indicates whether the project should use web sockets with Uvicorn + Gunicorn. +You can enable web sockets if you select ``use_async`` option when creating a project. That indicates whether the project can use web sockets with Uvicorn + Gunicorn. Usage ----- @@ -19,14 +19,7 @@ JavaScript example: :: undefined pong! -If you are using nGinx instead of Traefik, you should add these lines to nGinx config: :: - location /websocket/ { - proxy_pass http://backend; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_read_timeout 86400; - } +If you don't use Traefik, you might have to configure your reverse proxy accordingly (example with Nginx_). -Source: https://www.nginx.com/blog/websocket-nginx/ +.. _Nginx: https://www.nginx.com/blog/websocket-nginx/ From 4eca81edc2417349f133379b690ead674aab6694 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 23 Jun 2020 03:55:23 -0700 Subject: [PATCH 78/82] Update mypy from 0.781 to 0.782 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index f1307a22..38f4744f 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -14,7 +14,7 @@ watchgod==0.6 # https://github.com/samuelcolvin/watchgod # Testing # ------------------------------------------------------------------------------ -mypy==0.781 # https://github.com/python/mypy +mypy==0.782 # https://github.com/python/mypy django-stubs==1.5.0 # https://github.com/typeddjango/django-stubs pytest==5.4.3 # https://github.com/pytest-dev/pytest pytest-sugar==0.9.3 # https://github.com/Frozenball/pytest-sugar From f3a511a65690521bf367ff6cd6bf569f43ec3670 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 23 Jun 2020 08:34:22 -0700 Subject: [PATCH 79/82] Update ipdb from 0.13.2 to 0.13.3 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index f1307a22..275e98cc 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -1,7 +1,7 @@ -r ./base.txt Werkzeug==1.0.1 # https://github.com/pallets/werkzeug -ipdb==0.13.2 # https://github.com/gotcha/ipdb +ipdb==0.13.3 # https://github.com/gotcha/ipdb Sphinx==3.1.1 # https://github.com/sphinx-doc/sphinx {%- if cookiecutter.use_docker == 'y' %} psycopg2==2.8.5 --no-binary psycopg2 # https://github.com/psycopg/psycopg2 From 3cfea4c943891b653fa04c1940bc0ea8212efd1d Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sat, 27 Jun 2020 12:07:08 -0700 Subject: [PATCH 80/82] Update tox from 3.15.2 to 3.16.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 44804e0e..f3cdd2f6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ flake8-isort==3.0.0 # Testing # ------------------------------------------------------------------------------ -tox==3.15.2 +tox==3.16.0 pytest==5.4.3 pytest-cookies==0.5.1 pytest-instafail==0.4.2 From 8447699c937fd37719dd488872fe8c8155553f4c Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Mon, 29 Jun 2020 05:35:40 -0700 Subject: [PATCH 81/82] Update django-extensions from 2.2.9 to 3.0.0 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 4571fd0f..d127e45e 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -36,6 +36,6 @@ pre-commit==2.5.1 # https://github.com/pre-commit/pre-commit factory-boy==2.12.0 # https://github.com/FactoryBoy/factory_boy django-debug-toolbar==2.2 # https://github.com/jazzband/django-debug-toolbar -django-extensions==2.2.9 # https://github.com/django-extensions/django-extensions +django-extensions==3.0.0 # https://github.com/django-extensions/django-extensions django-coverage-plugin==1.8.0 # https://github.com/nedbat/django_coverage_plugin pytest-django==3.9.0 # https://github.com/pytest-dev/pytest-django From a9688adc0e58ce2afe4b328d882451e79bdd26e7 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Mon, 29 Jun 2020 15:27:53 -0400 Subject: [PATCH 82/82] Update ugettext_lazy to gettext_lazy --- .../{{cookiecutter.project_slug}}/users/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/forms.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/forms.py index 25065419..ba848b85 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/forms.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/users/forms.py @@ -1,6 +1,6 @@ from django.contrib.auth import forms, get_user_model from django.core.exceptions import ValidationError -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ User = get_user_model()