add settings for prod, debug toolbar
This commit is contained in:
parent
1f4a9c13be
commit
4811fbeada
3 changed files with 32 additions and 5 deletions
|
@ -10,8 +10,11 @@ For the full list of settings and their values, see
|
|||
https://docs.djangoproject.com/en/3.2/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
env_prefix = "HACKENS_ORGA_"
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
@ -20,12 +23,21 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = "django-insecure-d4qh9v-en$&f%$j$jyhqkn_th#ow-e22bs^stx(n33sg-eyfhd"
|
||||
SECRET_KEY = os.environ.get(
|
||||
f"{env_prefix}SECRET_KEY",
|
||||
"django-insecure-d4qh9v-en$&f%$j$jyhqkn_th#ow-e22bs^stx(n33sg-eyfhd",
|
||||
)
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = os.environ.get(f"{env_prefix}DEBUG", "1") != "0"
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
ALLOWED_HOSTS = os.environ.get(
|
||||
f"{env_prefix}ALLOWED_HOSTS", "127.0.0.1,localhost"
|
||||
).split(",")
|
||||
|
||||
INTERNAL_IPS = [
|
||||
"127.0.0.1",
|
||||
]
|
||||
|
||||
# Application definition
|
||||
|
||||
|
@ -46,6 +58,7 @@ INSTALLED_APPS = [
|
|||
"shared",
|
||||
]
|
||||
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
|
@ -56,6 +69,14 @@ MIDDLEWARE = [
|
|||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
]
|
||||
|
||||
if DEBUG:
|
||||
INSTALLED_APPS += [
|
||||
"debug_toolbar",
|
||||
]
|
||||
MIDDLEWARE = [
|
||||
"debug_toolbar.middleware.DebugToolbarMiddleware",
|
||||
] + MIDDLEWARE
|
||||
|
||||
ROOT_URLCONF = "hackens_orga.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
|
@ -83,6 +104,9 @@ AUTHENTICATION_BACKENDS = [
|
|||
"authens.backends.ENSCASBackend",
|
||||
]
|
||||
|
||||
AUTHENS_ALLOW_STAFF = True
|
||||
AUTHENS_USE_OLDCAS = False
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
LOGIN_URL = reverse_lazy("authens:login")
|
||||
|
@ -90,7 +114,6 @@ LOGIN_URL = reverse_lazy("authens:login")
|
|||
LOGOUT_REDIRECT_URL = "/"
|
||||
LOGIN_REDIRECT_URL = "/"
|
||||
|
||||
AUTHENS_USE_OLDCAS = False
|
||||
|
||||
# Django-rest-framework
|
||||
# https://www.django-rest-framework.org/
|
||||
|
@ -106,10 +129,12 @@ REST_FRAMEWORK = {
|
|||
# Database
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
||||
|
||||
DB_FILE = os.environ.get(f"{env_prefix}DB_FILE", BASE_DIR / "db.sqlite3")
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": BASE_DIR / "db.sqlite3",
|
||||
"NAME": DB_FILE,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,5 +23,6 @@ urlpatterns = [
|
|||
path("api/budget/", include("budget.urls")),
|
||||
path("api/agent/", include("agent.urls")),
|
||||
# path("api/wishlist/", include("wishlist.urls")),
|
||||
path('__debug__/', include('debug_toolbar.urls')),
|
||||
path("", include("frontend.urls")),
|
||||
]
|
||||
|
|
|
@ -15,6 +15,7 @@ pkgs.mkShell {
|
|||
ps.black
|
||||
ps.isort
|
||||
ps.djangorestframework
|
||||
ps.django-debug-toolbar
|
||||
ps.authens
|
||||
# (ps.django-extensions.override { inherit django; })
|
||||
# ps.django-compressor
|
||||
|
|
Loading…
Reference in a new issue