From df4b6780db605a178caed31e8cbab048edc365e2 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Mon, 8 Nov 2021 17:16:57 -0500 Subject: [PATCH] refactor: Split Django project from Django application --- .github/workflows/ci.yml | 1 - backend/core/__init__.py | 0 backend/core/asgi.py | 16 ++++++++++++++++ backend/{dqt => core}/settings.py | 4 ++-- backend/core/urls.py | 5 +++++ backend/{dqt => core}/wsgi.py | 6 +++--- backend/gunicorn_runner.sh | 2 +- backend/manage.py | 3 ++- docs/index.rst | 1 + 9 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 backend/core/__init__.py create mode 100644 backend/core/asgi.py rename backend/{dqt => core}/settings.py (99%) create mode 100644 backend/core/urls.py rename backend/{dqt => core}/wsgi.py (59%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3887e5d1..bb07d1f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,6 @@ jobs: PYTHONWARNINGS: error,ignore:::tastypie.resources DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres PELICAN_BACKEND_DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres - DJANGO_SETTINGS_MODULE: dqt.settings # Tastypie 0.14.3 has a missing migration. run: | ./manage.py migrate diff --git a/backend/core/__init__.py b/backend/core/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/backend/core/asgi.py b/backend/core/asgi.py new file mode 100644 index 00000000..6373a41a --- /dev/null +++ b/backend/core/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for core project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") + +application = get_asgi_application() diff --git a/backend/dqt/settings.py b/backend/core/settings.py similarity index 99% rename from backend/dqt/settings.py rename to backend/core/settings.py index 6e17b992..5f1d09f9 100644 --- a/backend/dqt/settings.py +++ b/backend/core/settings.py @@ -66,7 +66,7 @@ "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = "dqt.urls" +ROOT_URLCONF = "core.urls" TEMPLATES = [ { @@ -85,7 +85,7 @@ }, ] -WSGI_APPLICATION = "dqt.wsgi.application" +WSGI_APPLICATION = "core.wsgi.application" # Database diff --git a/backend/core/urls.py b/backend/core/urls.py new file mode 100644 index 00000000..61d192c1 --- /dev/null +++ b/backend/core/urls.py @@ -0,0 +1,5 @@ +from django.urls import include, path + +urlpatterns = [ + path("", include("dqt.urls"), name="api"), +] diff --git a/backend/dqt/wsgi.py b/backend/core/wsgi.py similarity index 59% rename from backend/dqt/wsgi.py rename to backend/core/wsgi.py index 8c28fa9a..b3b5ad3a 100644 --- a/backend/dqt/wsgi.py +++ b/backend/core/wsgi.py @@ -1,16 +1,16 @@ """ -WSGI config for dqt project. +WSGI config for core project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dqt.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") application = get_wsgi_application() diff --git a/backend/gunicorn_runner.sh b/backend/gunicorn_runner.sh index 80d51b70..c34c8c0a 100755 --- a/backend/gunicorn_runner.sh +++ b/backend/gunicorn_runner.sh @@ -1,2 +1,2 @@ #!/bin/sh -gunicorn --bind 0.0.0.0:$1 --timeout 120 dqt.wsgi -c gunicorn_docker.py \ No newline at end of file +gunicorn --bind 0.0.0.0:$1 --timeout 120 core.wsgi -c gunicorn_docker.py \ No newline at end of file diff --git a/backend/manage.py b/backend/manage.py index db2a7a4c..4e20ce5e 100755 --- a/backend/manage.py +++ b/backend/manage.py @@ -5,7 +5,8 @@ def main(): - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dqt.settings") + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/docs/index.rst b/docs/index.rst index dc55c4f6..db245157 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,3 +19,4 @@ Set up the git pre-commit hook: backend/index frontend/index + changelog