diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/app/__init__.py | 0 | ||||
-rw-r--r-- | app/app/asgi.py | 16 | ||||
-rw-r--r-- | app/app/settings.py | 133 | ||||
-rw-r--r-- | app/app/urls.py | 21 | ||||
-rw-r--r-- | app/app/wsgi.py | 16 | ||||
-rw-r--r-- | app/example/__init__.py | 0 | ||||
-rw-r--r-- | app/example/admin.py | 5 | ||||
-rw-r--r-- | app/example/apps.py | 5 | ||||
-rw-r--r-- | app/example/migrations/0001_initial.py | 24 | ||||
-rw-r--r-- | app/example/migrations/__init__.py | 0 | ||||
-rw-r--r-- | app/example/models.py | 13 | ||||
-rw-r--r-- | app/example/tests.py | 3 | ||||
-rw-r--r-- | app/example/views.py | 3 | ||||
-rwxr-xr-x | app/manage.py | 22 |
14 files changed, 261 insertions, 0 deletions
diff --git a/app/app/__init__.py b/app/app/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/app/__init__.py diff --git a/app/app/asgi.py b/app/app/asgi.py new file mode 100644 index 0000000..7d386be --- /dev/null +++ b/app/app/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for app 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.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') + +application = get_asgi_application() diff --git a/app/app/settings.py b/app/app/settings.py new file mode 100644 index 0000000..38737ce --- /dev/null +++ b/app/app/settings.py @@ -0,0 +1,133 @@ +""" +Django settings for app project. + +Generated by 'django-admin startproject' using Django 3.1.5. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.1/ref/settings/ +""" + +import os +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "kcq6+9o_aoq94+==^1g7kx(_)!0+@12f47fxto3gga*r37mml9" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = os.environ.get("DEBUG", True) + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "example", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", +] + +ROOT_URLCONF = "app.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", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "app.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/3.1/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.1/howto/static-files/ + +STATIC_URL = "/static/" + +# S3 configuration + +DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" + +AWS_ACCESS_KEY_ID = os.environ.get("AWS_ACCESS_KEY_ID", "access-key") +AWS_SECRET_ACCESS_KEY = os.environ.get("AWS_SECRET_ACCESS_KEY", "secret-key") +AWS_STORAGE_BUCKET_NAME = os.environ.get("AWS_STORAGE_BUCKET_NAME", "my-local-bucket") + +if DEBUG: + AWS_S3_ENDPOINT_URL = "http://minio:9000" diff --git a/app/app/urls.py b/app/app/urls.py new file mode 100644 index 0000000..1192fe4 --- /dev/null +++ b/app/app/urls.py @@ -0,0 +1,21 @@ +"""app URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/app/app/wsgi.py b/app/app/wsgi.py new file mode 100644 index 0000000..8ab68e5 --- /dev/null +++ b/app/app/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for app 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.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') + +application = get_wsgi_application() diff --git a/app/example/__init__.py b/app/example/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/example/__init__.py diff --git a/app/example/admin.py b/app/example/admin.py new file mode 100644 index 0000000..b77621a --- /dev/null +++ b/app/example/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin + +from example import models + +admin.site.register(models.Person) diff --git a/app/example/apps.py b/app/example/apps.py new file mode 100644 index 0000000..dbb0083 --- /dev/null +++ b/app/example/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ExampleConfig(AppConfig): + name = 'example' diff --git a/app/example/migrations/0001_initial.py b/app/example/migrations/0001_initial.py new file mode 100644 index 0000000..a2f5d32 --- /dev/null +++ b/app/example/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 3.1.5 on 2021-01-10 16:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Person', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(max_length=50)), + ('last_name', models.CharField(max_length=50)), + ('date_of_birth', models.DateField()), + ('picture', models.ImageField(upload_to='')), + ], + ), + ] diff --git a/app/example/migrations/__init__.py b/app/example/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/example/migrations/__init__.py diff --git a/app/example/models.py b/app/example/models.py new file mode 100644 index 0000000..0632304 --- /dev/null +++ b/app/example/models.py @@ -0,0 +1,13 @@ +from django.db import models + + +class Person(models.Model): + """This is a demo person model""" + + first_name = models.CharField(max_length=50) + last_name = models.CharField(max_length=50) + date_of_birth = models.DateField() + picture = models.ImageField() + + def __str__(self): + return f"{self.first_name} {self.last_name} {str(self.date_of_birth)}" diff --git a/app/example/tests.py b/app/example/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/app/example/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/app/example/views.py b/app/example/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/app/example/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/app/manage.py b/app/manage.py new file mode 100755 index 0000000..4931389 --- /dev/null +++ b/app/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.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() |