feat: load settings from env
This commit is contained in:
parent
fbfeeaefea
commit
59a3bff173
|
@ -0,0 +1,9 @@
|
|||
ALLOWED_HOSTS=.localhost,127.0.0.1,[::1]
|
||||
|
||||
DATABASE_URL=
|
||||
|
||||
DEBUG=False
|
||||
|
||||
SECRET_KEY=
|
||||
|
||||
TIME_ZONE=UTC
|
|
@ -12,20 +12,25 @@ https://docs.djangoproject.com/en/5.1/ref/settings/
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from environ import Env
|
||||
|
||||
env = Env(DEBUG=(bool, False))
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
Env.read_env(BASE_DIR / ".env")
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = "django-insecure-ed5#_cecl9g_7c%c@!v7#0bz)8y(nscc80%z%b^sm&rw1!%m+j"
|
||||
SECRET_KEY = env("SECRET_KEY")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = env("DEBUG")
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS")
|
||||
|
||||
|
||||
# Application definition
|
||||
|
@ -79,10 +84,11 @@ WSGI_APPLICATION = "lelcsc.wsgi.application"
|
|||
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": BASE_DIR / "db.sqlite3",
|
||||
}
|
||||
"default": (
|
||||
env.db("DATABASE_URL")
|
||||
if env("DATABASE_URL")
|
||||
else {"ENGINE": "django.db.backends.sqlite3", "NAME": BASE_DIR / "db.sqlite3"}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +116,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
|
||||
LANGUAGE_CODE = "en-us"
|
||||
|
||||
TIME_ZONE = "UTC"
|
||||
TIME_ZONE = env("TIME_ZONE")
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
|
|
Loading…
Reference in New Issue