From a316eb928b9ba827665d9ad1e662a1e49bac723c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 27 Nov 2016 22:10:28 +0000 Subject: [PATCH] use seperate setting for disabling admin --- project/settings.py | 3 ++- project/urls.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/project/settings.py b/project/settings.py index 60ed455..7af97a3 100755 --- a/project/settings.py +++ b/project/settings.py @@ -7,6 +7,7 @@ ALLOWED_HOSTS = ['*'] # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.environ['DEBUG'] +ENABLE_ADMIN = DEBUG # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.environ['SECRET_KEY'] @@ -47,7 +48,7 @@ INSTALLED_APPS = [ 'project.search', ] -if DEBUG: +if ENABLE_ADMIN: INSTALLED_APPS += ['django.contrib.admin'] # Harden Django! diff --git a/project/urls.py b/project/urls.py index a907951..cdbddd2 100755 --- a/project/urls.py +++ b/project/urls.py @@ -16,13 +16,14 @@ urlpatterns = [ url(r'', include(wagtail_urls)), ] +if settings.ENABLE_ADMIN: + urlpatterns = [url(r'^django-admin/', include(admin.site.urls))] + urlpatterns + if settings.DEBUG: from django.conf.urls.static import static from django.contrib.staticfiles.urls import staticfiles_urlpatterns - urlpatterns = [url(r'^django-admin/', include(admin.site.urls))] + urlpatterns - # Serve static and media files from development server urlpatterns += staticfiles_urlpatterns() urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)