Add whitenoise for gunicorn static file serving.

This commit is contained in:
Christopher Charbonneau Wells 2017-10-23 05:07:35 -04:00
parent 909c391451
commit ac5387428e
3 changed files with 15 additions and 1 deletions

View File

@ -12,6 +12,7 @@ pandas = "*"
faker = "*" faker = "*"
dj-database-url = "*" dj-database-url = "*"
gunicorn = "*" gunicorn = "*"
whitenoise = "*"
[dev-packages] [dev-packages]
coveralls = "*" coveralls = "*"

5
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "52db700b9c061baeb935565e2910f5205547ba93306d53f12634b7a0a4c3cb02" "sha256": "b9baed35cbefffb676928f6379dbeee78e94efa96382465afabc49c2e1685a44"
}, },
"requires": {}, "requires": {},
"sources": [ "sources": [
@ -86,6 +86,9 @@
}, },
"urllib3": { "urllib3": {
"version": "==1.22" "version": "==1.22"
},
"whitenoise": {
"version": "==3.3.1"
} }
}, },
"develop": { "develop": {

View File

@ -36,6 +36,9 @@ INSTALLED_APPS = [
MIDDLEWARE = [ MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
@ -104,6 +107,13 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/ # https://docs.djangoproject.com/en/1.11/howto/static-files/
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_ROOT = os.path.join(BASE_DIR, 'static')