From 2aedcd31839c6c5eff15242497e13c6618353d86 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 12 Apr 2020 14:41:27 +0100 Subject: [PATCH] init Django project --- manage.py | 21 +++++++++++++ requirements.txt | 1 + scripts/start.sh | 7 +++++ scripts/test.sh | 17 ++++++++++ website/__init__.py | 0 website/settings.py | 75 +++++++++++++++++++++++++++++++++++++++++++++ website/urls.py | 3 ++ website/wsgi.py | 16 ++++++++++ 8 files changed, 140 insertions(+) create mode 100755 manage.py create mode 100755 scripts/start.sh create mode 100755 scripts/test.sh create mode 100644 website/__init__.py create mode 100644 website/settings.py create mode 100644 website/urls.py create mode 100644 website/wsgi.py diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..bb1dd90 --- /dev/null +++ b/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'website.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt index e69de29..7073226 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +django==3.0.5 diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..d8b4b05 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +export PATH=env/bin:${PATH} + +./manage.py runserver diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..2810d47 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e + +export PATH=env/bin:${PATH} + +echo "> Running formatter..." +black website/ --check + +echo "> Running linter..." +flake8 website/ + +echo "> Running isort..." +isort -rc -c website/ + +echo "> Running type checker..." +mypy website/ diff --git a/website/__init__.py b/website/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/website/settings.py b/website/settings.py new file mode 100644 index 0000000..c68f350 --- /dev/null +++ b/website/settings.py @@ -0,0 +1,75 @@ +""" +Django settings for website project. + +Generated by 'django-admin startproject' using Django 3.0.5. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.0/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "gd(%^4!762m4y*c56t(ppm&-5+*a*6-&5)n%nc^aqfi%54^u_j" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.staticfiles", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "website.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + ], + }, + }, +] + +WSGI_APPLICATION = "website.wsgi.application" + +LANGUAGE_CODE = "en-gb" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.0/howto/static-files/ + +STATIC_URL = "/static/" diff --git a/website/urls.py b/website/urls.py new file mode 100644 index 0000000..e39cb2c --- /dev/null +++ b/website/urls.py @@ -0,0 +1,3 @@ +from django.urls import path + +urlpatterns = [] diff --git a/website/wsgi.py b/website/wsgi.py new file mode 100644 index 0000000..2ff8aaf --- /dev/null +++ b/website/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for website 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/3.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings") + +application = get_wsgi_application()