2020-05-09 15:48:51 +02:00
|
|
|
"""Django local development settings."""
|
2017-08-11 18:24:09 +02:00
|
|
|
import os
|
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
from . import bds_prod
|
|
|
|
from .cof_prod import BASE_DIR, INSTALLED_APPS, MIDDLEWARE, TESTING
|
2020-05-09 11:49:05 +02:00
|
|
|
|
2020-07-04 13:30:54 +02:00
|
|
|
from .cof_prod import * # NOQA
|
|
|
|
|
2020-05-09 15:48:51 +02:00
|
|
|
# ---
|
|
|
|
# Merge COF and BDS configs
|
|
|
|
# ---
|
|
|
|
|
|
|
|
for app in bds_prod.INSTALLED_APPS:
|
|
|
|
if app not in INSTALLED_APPS:
|
|
|
|
INSTALLED_APPS.append(app)
|
|
|
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
# Tweaks for debug/local development
|
|
|
|
# ---
|
|
|
|
|
2020-05-14 23:37:47 +02:00
|
|
|
ALLOWED_HOSTS = []
|
2020-05-09 11:49:05 +02:00
|
|
|
|
|
|
|
DEBUG = True
|
2020-05-09 15:48:51 +02:00
|
|
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
2020-05-09 11:49:05 +02:00
|
|
|
|
|
|
|
if TESTING:
|
|
|
|
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
|
|
|
|
|
|
|
|
STATIC_URL = "/static/"
|
2020-05-09 15:48:51 +02:00
|
|
|
MEDIA_URL = "/media/"
|
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
2017-08-09 21:48:20 +02:00
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
"default": {
|
|
|
|
"ENGINE": "django.db.backends.sqlite3",
|
2018-10-06 12:35:49 +02:00
|
|
|
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
2017-08-09 21:48:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Use the default cache backend for local development
|
2018-10-06 12:35:49 +02:00
|
|
|
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}
|
2017-08-09 21:48:20 +02:00
|
|
|
|
|
|
|
# Use the default in memory asgi backend for local development
|
|
|
|
CHANNEL_LAYERS = {
|
|
|
|
"default": {
|
|
|
|
"BACKEND": "asgiref.inmemory.ChannelLayer",
|
|
|
|
"ROUTING": "cof.routing.routing",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-09 11:49:05 +02:00
|
|
|
|
|
|
|
# ---
|
|
|
|
# Debug tool bar
|
|
|
|
# ---
|
|
|
|
|
|
|
|
|
|
|
|
def show_toolbar(request):
|
|
|
|
"""
|
2020-06-28 19:07:45 +02:00
|
|
|
On active la debug-toolbar en mode développement local sauf :
|
|
|
|
- dans l'admin où ça ne sert pas à grand chose;
|
|
|
|
- si la variable d'environnement DJANGO_NO_DDT est à 1 → ça permet de la désactiver
|
|
|
|
sans modifier ce fichier en exécutant `export DJANGO_NO_DDT=1` dans le terminal
|
|
|
|
qui lance `./manage.py runserver`.
|
|
|
|
|
|
|
|
Autre side effect de cette fonction : on ne fait pas la vérification de INTERNAL_IPS
|
|
|
|
que ferait la debug-toolbar par défaut, ce qui la fait fonctionner aussi à
|
|
|
|
l'intérieur de Vagrant (comportement non testé depuis un moment…)
|
2020-05-09 11:49:05 +02:00
|
|
|
"""
|
|
|
|
env_no_ddt = bool(os.environ.get("DJANGO_NO_DDT", None))
|
|
|
|
return DEBUG and not env_no_ddt and not request.path.startswith("/admin/")
|
|
|
|
|
|
|
|
|
|
|
|
if not TESTING:
|
|
|
|
INSTALLED_APPS += ["debug_toolbar"]
|
|
|
|
MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE
|
|
|
|
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}
|