From 6022eb15d5139487fe02bf0f0618252516fe221c Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Mon, 22 Jan 2018 12:01:07 -0500 Subject: [PATCH] Add ability to enable Google analytics for production sites --- get_together/settings.py | 9 +++++++++ get_together/templates/get_together/base.html | 13 +++++++++++++ requirements.txt | 1 + 3 files changed, 23 insertions(+) diff --git a/get_together/settings.py b/get_together/settings.py index 946f89b..29ac56b 100644 --- a/get_together/settings.py +++ b/get_together/settings.py @@ -88,6 +88,7 @@ TEMPLATES = [ 'django.contrib.messages.context_processors.messages', 'social_django.context_processors.backends', 'social_django.context_processors.login_redirect', + 'django_settings_export.settings_export', ], }, }, @@ -145,6 +146,14 @@ USE_TZ = True STATIC_URL = '/static/' +GOOGLE_ANALYTICS_ID=None + +SETTINGS_EXPORT = [ + 'DEBUG', + 'GOOGLE_ANALYTICS_ID', +] + +# Keep this at the end of settings.py to allow overriding settings in local deployments try: from local_settings import * diff --git a/get_together/templates/get_together/base.html b/get_together/templates/get_together/base.html index feb84fc..c7dde29 100644 --- a/get_together/templates/get_together/base.html +++ b/get_together/templates/get_together/base.html @@ -8,6 +8,18 @@ Get Together + {% if settings.GOOGLE_ANALYTICS_ID %} + + + + {% endif %} + @@ -24,6 +36,7 @@ form { display: inline; } + diff --git a/requirements.txt b/requirements.txt index e623a5c..fd056de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,3 +16,4 @@ social-auth-app-django==2.1.0 social-auth-core==1.6.0 urllib3==1.22 dj-database-url==0.4.2 +django-settings-export==1.2.1