From bf2b317a2705823db3092d3e6fd8ec65a847a1ad Mon Sep 17 00:00:00 2001 From: Rehema Date: Wed, 21 Sep 2016 12:06:17 +0300 Subject: [PATCH 1/7] Add whitenoise to enable static files in Django production --- requirements.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/requirements.txt b/requirements.txt index 8a292a2d..281aee07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ boto==2.42.0 cssselect==0.9.2 cssutils==1.0.1 +decorator==4.0.10 dj-database-url==0.4.1 Django==1.10 django-appconf==1.0.1 @@ -9,12 +10,24 @@ django-ses-backend==0.1.1 djmail==0.11.0 futures==3.0.3 gunicorn==19.6.0 +ipdb==0.10.1 +ipython==5.1.0 +ipython-genutils==0.1.0 lxml==3.6.4 mock==2.0.0 pbr==1.10.0 +pexpect==4.2.1 +pickleshare==0.7.4 premailer==2.9.6 +prompt-toolkit==1.0.7 psycopg2==2.6.1 +ptyprocess==0.5.1 +Pygments==2.1.3 rcssmin==1.0.6 requests==2.9.1 rjsmin==1.0.12 +simplegeneric==0.8.1 six==1.10.0 +traitlets==4.3.0 +wcwidth==0.1.7 +whitenoise==3.2.1 From f80176b538371dfc8540045f2bdb3308d3851170 Mon Sep 17 00:00:00 2001 From: Rehema Date: Wed, 21 Sep 2016 12:07:10 +0300 Subject: [PATCH 2/7] Config static files --- hc/settings.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hc/settings.py b/hc/settings.py index 7ea5c2ca..5576e3b2 100644 --- a/hc/settings.py +++ b/hc/settings.py @@ -128,9 +128,15 @@ USE_TZ = True SITE_ROOT = "http://localhost:8000" PING_ENDPOINT = SITE_ROOT + "/ping/" PING_EMAIL_DOMAIN = HOST +STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') STATIC_URL = '/static/' -STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] -STATIC_ROOT = os.path.join(BASE_DIR, 'static-collected') +STATICFILES_DIRS = ( + os.path.join(PROJECT_ROOT, 'static'), +) +STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' +# STATIC_URL = '/static/' +# STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] +# STATIC_ROOT = os.path.join(BASE_DIR, 'static-collected') STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', From e8e308224a8b03e45f146d2ae3e6594b8e34a342 Mon Sep 17 00:00:00 2001 From: Rehema Date: Wed, 21 Sep 2016 12:36:24 +0300 Subject: [PATCH 3/7] Configured static files for deployment --- hc/settings.py | 10 ++-------- hc/urls.py | 6 ++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hc/settings.py b/hc/settings.py index 5576e3b2..7ea5c2ca 100644 --- a/hc/settings.py +++ b/hc/settings.py @@ -128,15 +128,9 @@ USE_TZ = True SITE_ROOT = "http://localhost:8000" PING_ENDPOINT = SITE_ROOT + "/ping/" PING_EMAIL_DOMAIN = HOST -STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') STATIC_URL = '/static/' -STATICFILES_DIRS = ( - os.path.join(PROJECT_ROOT, 'static'), -) -STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' -# STATIC_URL = '/static/' -# STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] -# STATIC_ROOT = os.path.join(BASE_DIR, 'static-collected') +STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] +STATIC_ROOT = os.path.join(BASE_DIR, 'static-collected') STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', diff --git a/hc/urls.py b/hc/urls.py index 12c23c67..248f0643 100644 --- a/hc/urls.py +++ b/hc/urls.py @@ -1,5 +1,7 @@ from django.conf.urls import include, url from django.contrib import admin +from django.conf import settings +from django.contrib.staticfiles import views urlpatterns = [ url(r'^admin/', include(admin.site.urls)), @@ -8,3 +10,7 @@ urlpatterns = [ url(r'^', include('hc.front.urls')), url(r'^', include('hc.payments.urls')) ] + +urlpatterns += [ + url(r'^static/?P.*)$', views.serve), +] \ No newline at end of file From 1016a4d0d68efe4f8d873f84a2c0cdef0217111e Mon Sep 17 00:00:00 2001 From: Rehema Date: Wed, 21 Sep 2016 12:40:36 +0300 Subject: [PATCH 4/7] (chore): Fix regex statement Typo on the static regex statement --- hc/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hc/urls.py b/hc/urls.py index 248f0643..2f985190 100644 --- a/hc/urls.py +++ b/hc/urls.py @@ -12,5 +12,5 @@ urlpatterns = [ ] urlpatterns += [ - url(r'^static/?P.*)$', views.serve), + url(r'^static/(?P.*)$', views.serve), ] \ No newline at end of file From 248057e4165ddae095ebe50496c36d3e8b8ab606 Mon Sep 17 00:00:00 2001 From: Rehema Date: Mon, 26 Sep 2016 11:48:12 +0300 Subject: [PATCH 5/7] Ch-remove-import-settings-module --- hc/urls.py | 1 - 1 file changed, 1 deletion(-) diff --git a/hc/urls.py b/hc/urls.py index 2f985190..a54e8eff 100644 --- a/hc/urls.py +++ b/hc/urls.py @@ -1,6 +1,5 @@ from django.conf.urls import include, url from django.contrib import admin -from django.conf import settings from django.contrib.staticfiles import views urlpatterns = [ From e737aab56a21f0688e1d5b4d5738c3d2015a01d3 Mon Sep 17 00:00:00 2001 From: Rehema Date: Mon, 26 Sep 2016 11:54:09 +0300 Subject: [PATCH 6/7] Ch-cleaned-up-requirements.txt --- requirements.txt | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/requirements.txt b/requirements.txt index 281aee07..ae497bc4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,33 +1,10 @@ -boto==2.42.0 -cssselect==0.9.2 -cssutils==1.0.1 -decorator==4.0.10 -dj-database-url==0.4.1 -Django==1.10 django-appconf==1.0.1 -django-compressor==2.1 django-ses-backend==0.1.1 +Django==1.10 +django_compressor==2.1 djmail==0.11.0 futures==3.0.3 -gunicorn==19.6.0 -ipdb==0.10.1 -ipython==5.1.0 -ipython-genutils==0.1.0 -lxml==3.6.4 -mock==2.0.0 -pbr==1.10.0 -pexpect==4.2.1 -pickleshare==0.7.4 premailer==2.9.6 -prompt-toolkit==1.0.7 psycopg2==2.6.1 -ptyprocess==0.5.1 -Pygments==2.1.3 -rcssmin==1.0.6 requests==2.9.1 -rjsmin==1.0.12 -simplegeneric==0.8.1 -six==1.10.0 -traitlets==4.3.0 -wcwidth==0.1.7 -whitenoise==3.2.1 +mock==2.0.0 From 8d7eb7a320342a2e7d4effe08cf8db1be17d81eb Mon Sep 17 00:00:00 2001 From: Rehema Date: Mon, 26 Sep 2016 14:45:10 +0300 Subject: [PATCH 7/7] Add dj-database-url-module --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index ae497bc4..f90fdae6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ premailer==2.9.6 psycopg2==2.6.1 requests==2.9.1 mock==2.0.0 +dj-database-url==0.4.1