Skip to content

Commit

Permalink
Do not show Django's builtin admin login page outside of development
Browse files Browse the repository at this point in the history
  • Loading branch information
Svetlitski committed Feb 19, 2020
1 parent 85c4c0d commit 425b510
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions csm_web/csm_web/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib.admin import AdminSite as DefaultAdminSite
from django.conf import settings


class AdminSite(DefaultAdminSite):
if settings.DJANGO_ENV != settings.DEVELOPMENT:
login_template = 'admin_login.html'
5 changes: 5 additions & 0 deletions csm_web/csm_web/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib.admin.apps import AdminConfig as DefaultAdminConfig


class AdminConfig(DefaultAdminConfig):
default_site = 'csm_web.admin.AdminSite'
4 changes: 2 additions & 2 deletions csm_web/csm_web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"csm_web.apps.AdminConfig",
"scheduler.apps.SchedulerConfig",
"rest_framework",
"social_django",
Expand All @@ -83,7 +83,7 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": ["./csm_web/csm_web/templates/csm_web/"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
Expand Down
6 changes: 6 additions & 0 deletions csm_web/csm_web/templates/csm_web/admin_login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!doctype html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=/">
</head>
</html>

0 comments on commit 425b510

Please sign in to comment.