From c566b4a8bbc4d9f578a0eae74680b5de0fb7d158 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 12 Apr 2021 09:55:30 +0200 Subject: [PATCH] Add initial django project --- .gitignore | 5 + README.md | 7 ++ userausfall/__init__.py | 0 userausfall/migrations/0001_initial.py | 44 ++++++++ userausfall/migrations/__init__.py | 0 userausfall/models.py | 5 + userausfall/settings.py | 135 +++++++++++++++++++++++++ userausfall/urls.py | 6 ++ userausfall/wsgi.py | 16 +++ 9 files changed, 218 insertions(+) create mode 100644 .gitignore create mode 100644 userausfall/__init__.py create mode 100644 userausfall/migrations/0001_initial.py create mode 100644 userausfall/migrations/__init__.py create mode 100644 userausfall/models.py create mode 100644 userausfall/settings.py create mode 100644 userausfall/urls.py create mode 100644 userausfall/wsgi.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2255bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +__pycache__/ + +/.idea/ + +/db.sqlite3 \ No newline at end of file diff --git a/README.md b/README.md index 9d3895d..88df55e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # userausfall +## Run the development server + +```shell +export DJANGO_SETTINGS_MODULE=userausfall.settings USERAUSFALL_SECRET_KEY=dev +python3 -m django migrate +python3 -m django runserver +``` diff --git a/userausfall/__init__.py b/userausfall/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/userausfall/migrations/0001_initial.py b/userausfall/migrations/0001_initial.py new file mode 100644 index 0000000..9bac07f --- /dev/null +++ b/userausfall/migrations/0001_initial.py @@ -0,0 +1,44 @@ +# Generated by Django 2.2.13 on 2021-04-12 07:48 + +import django.contrib.auth.models +import django.contrib.auth.validators +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0011_update_proxy_permissions'), + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ], + options={ + 'verbose_name': 'user', + 'verbose_name_plural': 'users', + 'abstract': False, + }, + managers=[ + ('objects', django.contrib.auth.models.UserManager()), + ], + ), + ] diff --git a/userausfall/migrations/__init__.py b/userausfall/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/userausfall/models.py b/userausfall/models.py new file mode 100644 index 0000000..3d30525 --- /dev/null +++ b/userausfall/models.py @@ -0,0 +1,5 @@ +from django.contrib.auth.models import AbstractUser + + +class User(AbstractUser): + pass diff --git a/userausfall/settings.py b/userausfall/settings.py new file mode 100644 index 0000000..e933f75 --- /dev/null +++ b/userausfall/settings.py @@ -0,0 +1,135 @@ +""" +Django settings for userausfall. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.2/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__))) +DATA_DIR = os.environ.get("USERAUSFALL_DATA_DIR", BASE_DIR) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = os.environ.get('USERAUSFALL_SECRET_KEY') + +# SECURITY WARNING: don't run with debug turned on in production! +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', + 'userausfall', + 'rest_framework', +] + +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 = 'userausfall.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 = 'userausfall.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(DATA_DIR, 'db.sqlite3'), + } +} + + +# User model +# + +AUTH_USER_MODEL = 'userausfall.User' + + +# Password validation +# https://docs.djangoproject.com/en/2.2/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/2.2/topics/i18n/ + +LANGUAGE_CODE = 'de-de' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.2/howto/static-files/ + +STATIC_URL = '/static/' + + +# Media files +# https://docs.djangoproject.com/en/2.2/topics/files/ + +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') + +MEDIA_URL = '/media/' diff --git a/userausfall/urls.py b/userausfall/urls.py new file mode 100644 index 0000000..22db1ce --- /dev/null +++ b/userausfall/urls.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/userausfall/wsgi.py b/userausfall/wsgi.py new file mode 100644 index 0000000..2d6fc6f --- /dev/null +++ b/userausfall/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for userausfall 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/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'userausfall.settings') + +application = get_wsgi_application()