Browse Source

added whitenoise to serve static files

master
Benni Baermann 4 years ago
parent
commit
c3e0fb250f
4 changed files with 23 additions and 11 deletions
  1. +12
    -1
      README.md
  2. +4
    -4
      foerderbarometer/settings.py
  3. +3
    -3
      foerderbarometer/settings_development.py
  4. +4
    -3
      foerderbarometer/settings_production.py

+ 12
- 1
README.md View File

@ -11,9 +11,20 @@ purpose: gather data from intern(WMDE) and extern(volunteers) forms to create a
python 3.8.2
django 3.1.1
django-formtools 2.2
whitenoise 5.2.0
## production setup
cp foerderbarometer/settings_production.py foerderbarometer/settings.py
edit /secrets.json
edit /secrets.json to contain something similar to
{
"DATABASE_PASSWORD": "THIS IS TOP SECRET!"
}
python manage.py collectstatic
add to cron one time a day:
python manage.py sendmails

+ 4
- 4
foerderbarometer/settings.py View File

@ -44,7 +44,9 @@ def get_secret(setting, secrets=secrets):
SECRET_KEY = '*&7p9#_n$@^%0z49s+7jpy@+j1rw_hqh05knyd6y2*!0)r&b6h'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False
STATIC_ROOT = BASE_DIR / 'staticfiles'
ALLOWED_HOSTS = ['*']
@ -59,14 +61,12 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# 'django.contrib.sites',
'formtools',
]
# SITE_ID = 1 # needed for contrib.sites
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',

+ 3
- 3
foerderbarometer/settings_development.py View File

@ -46,6 +46,8 @@ SECRET_KEY = '*&7p9#_n$@^%0z49s+7jpy@+j1rw_hqh05knyd6y2*!0)r&b6h'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
STATIC_ROOT = BASE_DIR / 'staticfiles'
ALLOWED_HOSTS = ['*']
@ -59,14 +61,12 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# 'django.contrib.sites',
'formtools',
]
# SITE_ID = 1 # needed for contrib.sites
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',

+ 4
- 3
foerderbarometer/settings_production.py View File

@ -48,7 +48,9 @@ def get_secret(setting, secrets=secrets):
SECRET_KEY = '*&7p9#_n$@^%0z49s+7jpy@+j1rw_hqh05knyd6y2*!0)r&b6h'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False
STATIC_ROOT = BASE_DIR / 'staticfiles'
ALLOWED_HOSTS = ['*']
@ -63,14 +65,13 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# 'django.contrib.sites',
'formtools',
]
# SITE_ID = 1 # needed for contrib.sites
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',

Loading…
Cancel
Save