diff --git a/Pipfile b/Pipfile index ad162d0..9736996 100644 --- a/Pipfile +++ b/Pipfile @@ -11,6 +11,7 @@ django = ">=2.0" "psycopg2" = "*" gunicorn = "*" dj-database-url = "*" +whitenoise = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 5e7898a..494a4f6 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "9fb9e609349b328fe1246414709266a39ab7efd41ba133bfda4076c00b39c133" + "sha256": "5da72a6548823b17ea8716c4c617ea7b612285f4c830b6950bf59edba6e1b005" }, "host-environment-markers": { "implementation_name": "cpython", @@ -97,6 +97,13 @@ "sha256:fae4cffc040921b8a2d60c6cf0b5d662c1190fe54d718271db4eb17d44a185b7" ], "version": "==2017.3" + }, + "whitenoise": { + "hashes": [ + "sha256:15f43b2e701821b95c9016cf469d29e2a546cb1c7dead584ba82c36f843995cf", + "sha256:9d81515f2b5b27051910996e1e860b1332e354d9e7bcf30c98f21dcb6713e0dd" + ], + "version": "==3.3.1" } }, "develop": {} diff --git a/richtext/settings.py b/richtext/settings.py index 00c03f5..89b6d40 100644 --- a/richtext/settings.py +++ b/richtext/settings.py @@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os +import dj_database_url # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -41,6 +42,9 @@ INSTALLED_APPS = [ ] MIDDLEWARE = [ + # Simplified static file serving. + # https://warehouse.python.org/project/whitenoise/ + 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -114,4 +118,19 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.0/howto/static-files/ +PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.9/howto/static-files/ +STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') STATIC_URL = '/static/' + +# Extra places for collectstatic to find static files. +STATICFILES_DIRS = ( + os.path.join(PROJECT_ROOT, 'static'), +) + +# Simplified static file serving. +# https://warehouse.python.org/project/whitenoise/ + +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'