Compare commits

...

2 Commits

Author SHA1 Message Date
Fred Pauchet f057380fdb Enable whitenoise to serve static files 2021-10-14 21:51:50 +02:00
Fred Pauchet 3d919c7edf Clean up settings.py (a little bit) 2021-10-14 21:46:45 +02:00
2 changed files with 14 additions and 12 deletions

View File

@ -10,11 +10,13 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import environ
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
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))
@ -28,16 +30,12 @@ SECRET_KEY = env(
DATABASES = {"default": env.db("DATABASE_URL", default="sqlite:///db.sqlite3")}
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
ALLOWED_HOSTS = ["*"]
# Application definition
INSTALLED_APPS = (
"django.contrib.contenttypes",
"django.contrib.admin",
# 'django.contrib.admindocs',
"django.contrib.auth",
"django.contrib.sessions",
"django.contrib.messages",
@ -56,6 +54,7 @@ INSTALLED_APPS = (
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
#'django.middleware.csrf.CsrfViewMiddleware',
@ -105,19 +104,20 @@ LOGIN_URL = "/login/"
LOGOUT_URL = "/logout/"
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
MEDIA_URL = "/media/" # https://media.khana.be
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
STATIC_URL = "/static/"
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),)
MEDIA_URL = "/media/" # https://media.khana.be
STATIC_ROOT = BASE_DIR / 'staticfiles'
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
DEBUG_TOOLBAR_CONFIG = {
"JQUERY_URL": STATIC_URL + "js/jquery-2.1.4.min.js",
}
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

View File

@ -10,5 +10,7 @@ reportlab==3.5.67
simplejson==3.17.2
Sphinx==3.5.4
whitenoise==5.3
gunicorn
psycopg2