[django] configure settings via django-environ
django-environ reads from a file `.env` which is not under version control. Perhaps we should add a `.env.dist` or similar.
This commit is contained in:
parent
9f22508d4b
commit
5837d0d86c
1 changed files with 7 additions and 7 deletions
|
@ -10,20 +10,23 @@ For the full list of settings and their values, see
|
|||
https://docs.djangoproject.com/en/5.1/ref/settings/
|
||||
"""
|
||||
|
||||
import environ
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
env = environ.Env(DEBUG=(bool, False))
|
||||
environ.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-x=%#_wxu0h=d*m#seui9+mjh3vu7of8+4+gpwj@556$un0r1%$"
|
||||
SECRET_KEY = env("SECRET_KEY")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = env("DEBUG")
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
@ -74,10 +77,7 @@ WSGI_APPLICATION = "config.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(),
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue