Django-5.2-Projekt mit uv, django-environ und Docker-Compose-Setup (web + Postgres, WeasyPrint-Systembibliotheken im Image). Vollständiges Datenmodell (Firma, Therapeut, Auftraggeber, Teilnehmer, Leistungsart, Leistung, InvoiceLog, InvoiceCounter) mit Admin, Login-Flow und Platzhalter-Dashboard. Fortschritt in FORTSCHRITT.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016yy3uodsai6Ytt3GJ7tBdz
129 lines
3.5 KiB
Python
129 lines
3.5 KiB
Python
"""
|
|
Django settings for the Abrechnungssystem project.
|
|
|
|
Settings are read from environment variables via django-environ so the same
|
|
image runs in dev (docker-compose.override.yml) and prod (docker-compose.yml).
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
import environ
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
|
|
env = environ.Env(
|
|
DEBUG=(bool, False),
|
|
ALLOWED_HOSTS=(list, ["*"]),
|
|
)
|
|
|
|
# Read a local .env if present (Docker passes env directly, so it's optional).
|
|
environ.Env.read_env(BASE_DIR / ".env")
|
|
|
|
SECRET_KEY = env("SECRET_KEY", default="django-insecure-dev-only-change-me")
|
|
|
|
DEBUG = env("DEBUG")
|
|
|
|
ALLOWED_HOSTS = env("ALLOWED_HOSTS")
|
|
|
|
CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", default=[])
|
|
|
|
|
|
# Application definition
|
|
|
|
INSTALLED_APPS = [
|
|
"django.contrib.admin",
|
|
"django.contrib.auth",
|
|
"django.contrib.contenttypes",
|
|
"django.contrib.sessions",
|
|
"django.contrib.messages",
|
|
"django.contrib.staticfiles",
|
|
"crispy_forms",
|
|
"crispy_bootstrap5",
|
|
"django_tables2",
|
|
"abrechnung",
|
|
]
|
|
|
|
MIDDLEWARE = [
|
|
"django.middleware.security.SecurityMiddleware",
|
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
|
"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 = "config.urls"
|
|
|
|
TEMPLATES = [
|
|
{
|
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
"DIRS": [BASE_DIR / "templates"],
|
|
"APP_DIRS": True,
|
|
"OPTIONS": {
|
|
"context_processors": [
|
|
"django.template.context_processors.request",
|
|
"django.contrib.auth.context_processors.auth",
|
|
"django.contrib.messages.context_processors.messages",
|
|
],
|
|
},
|
|
},
|
|
]
|
|
|
|
WSGI_APPLICATION = "config.wsgi.application"
|
|
|
|
|
|
# Database — DATABASE_URL, e.g. postgres://user:pass@db:5432/abrechnung.
|
|
# Falls back to a local SQLite file when DATABASE_URL is unset (e.g. quick tests).
|
|
DATABASES = {
|
|
"default": env.db(
|
|
"DATABASE_URL",
|
|
default=f"sqlite:///{BASE_DIR / 'db.sqlite3'}",
|
|
)
|
|
}
|
|
|
|
|
|
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 — German-facing UI.
|
|
LANGUAGE_CODE = "de-de"
|
|
TIME_ZONE = "Europe/Berlin"
|
|
USE_I18N = True
|
|
USE_TZ = True
|
|
|
|
|
|
# Static files
|
|
STATIC_URL = "static/"
|
|
STATIC_ROOT = BASE_DIR / "staticfiles"
|
|
STATICFILES_DIRS = [BASE_DIR / "static"]
|
|
STORAGES = {
|
|
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
|
|
"staticfiles": {
|
|
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage",
|
|
},
|
|
}
|
|
|
|
# Media (only used for the seller logo — not for invoice documents).
|
|
MEDIA_URL = "media/"
|
|
MEDIA_ROOT = BASE_DIR / "media"
|
|
|
|
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
|
|
# Auth flow
|
|
LOGIN_URL = "login"
|
|
LOGIN_REDIRECT_URL = "dashboard"
|
|
LOGOUT_REDIRECT_URL = "login"
|
|
|
|
# crispy-forms
|
|
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
|
|
CRISPY_TEMPLATE_PACK = "bootstrap5"
|
|
|
|
DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap5.html"
|