From 5a1f2dacfd8aaeb3d442373fec130fedfb12ee91 Mon Sep 17 00:00:00 2001 From: sage Date: Mon, 28 Sep 2020 17:20:05 +0700 Subject: [PATCH] template: Convert project to template Use curly braces for project_name, so that it's automatically replaced with the project name on project generation. --- .github/workflows/tnd.yml | 4 ++-- .gitlab-ci.yml | 4 ++-- Procfile | 2 +- README.md | 2 +- manage.py | 2 +- project_name/asgi.py | 4 ++-- project_name/settings.py | 6 +++--- project_name/urls.py | 2 +- project_name/wsgi.py | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tnd.yml b/.github/workflows/tnd.yml index c1bc7d3..e665d82 100644 --- a/.github/workflows/tnd.yml +++ b/.github/workflows/tnd.yml @@ -29,7 +29,7 @@ jobs: run: python manage.py collectstatic --no-input - name: Run unit tests run: | - coverage run --parallel --include="./*" --omit="manage.py,project_name/*" \ + coverage run --parallel --include="./*" --omit="manage.py,{{ project_name }}/*" \ manage.py test --exclude-tag=functional - name: Upload unit test coverage uses: actions/upload-artifact@v2 @@ -59,7 +59,7 @@ jobs: run: python manage.py collectstatic --no-input - name: Run functional tests run: | - coverage run --parallel --include="./*" --omit="manage.py,project_name/*" \ + coverage run --parallel --include="./*" --omit="manage.py,{{ project_name }}/*" \ manage.py test --tag=functional - name: Upload functional test coverage uses: actions/upload-artifact@v2 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 255ecff..a26c1cd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,7 +32,7 @@ UnitTest: before_script: - *django_before_script script: - - coverage run --parallel --include="./*" --omit="manage.py,project_name/*" + - coverage run --parallel --include="./*" --omit="manage.py,{{ project_name }}/*" manage.py test --exclude-tag=functional FunctionalTest: @@ -43,7 +43,7 @@ FunctionalTest: - apt-get update -q && apt-get install -yq chromium-driver - *django_before_script script: - - coverage run --parallel --include="./*" --omit="manage.py,project_name/*" + - coverage run --parallel --include="./*" --omit="manage.py,{{ project_name }}/*" manage.py test --tag=functional diff --git a/Procfile b/Procfile index 4834c8a..56d2f7e 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ migrate: python manage.py migrate -web: gunicorn project_name.wsgi +web: gunicorn {{ project_name }}.wsgi diff --git a/README.md b/README.md index 4185b59..74ce07d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# django-template-heroku +# {{ project_name }} [![Test and Deploy][actions-badge]][commits-gh] [![pipeline status][pipeline-badge]][commits-gl] diff --git a/manage.py b/manage.py index 1a1453b..a628884 100755 --- a/manage.py +++ b/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{{ project_name }}.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/project_name/asgi.py b/project_name/asgi.py index a0ca563..7e6c6f9 100644 --- a/project_name/asgi.py +++ b/project_name/asgi.py @@ -1,5 +1,5 @@ """ -ASGI config for project_name project. +ASGI config for {{ project_name }} project. It exposes the ASGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{{ project_name }}.settings') application = get_asgi_application() diff --git a/project_name/settings.py b/project_name/settings.py index 7804e47..fdee7d0 100644 --- a/project_name/settings.py +++ b/project_name/settings.py @@ -1,5 +1,5 @@ """ -Django settings for project_name project. +Django settings for {{ project_name }} project. Generated by 'django-admin startproject' using Django 3.1.1. @@ -71,7 +71,7 @@ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -ROOT_URLCONF = 'project_name.urls' +ROOT_URLCONF = '{{ project_name }}.urls' TEMPLATES = [ { @@ -91,7 +91,7 @@ }, ] -WSGI_APPLICATION = 'project_name.wsgi.application' +WSGI_APPLICATION = '{{ project_name }}.wsgi.application' # Database diff --git a/project_name/urls.py b/project_name/urls.py index 1f83f0d..8b8d44a 100644 --- a/project_name/urls.py +++ b/project_name/urls.py @@ -1,4 +1,4 @@ -"""project_name URL Configuration +"""{{ project_name }} URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.1/topics/http/urls/ diff --git a/project_name/wsgi.py b/project_name/wsgi.py index 605d100..552e253 100644 --- a/project_name/wsgi.py +++ b/project_name/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for project_name project. +WSGI config for {{ project_name }} project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_name.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{{ project_name }}.settings') application = get_wsgi_application()