Skip to content

Commit

Permalink
A Proof of concept solution to server django admin page at admin.doma…
Browse files Browse the repository at this point in the history
…in.com Can be used to show wagtail admin (probably).

Uses 'django-host' to server subdomain
  • Loading branch information
hato1883 committed Jan 21, 2024
1 parent fdadf3b commit 94cbffc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
django_recaptcha==3.0.0
Django[argon2]==3.2.17
wagtail==2.16.2
# Allows subdomains
django-hosts==6.0

# External Libraries
requests==2.28.2
Expand Down
14 changes: 14 additions & 0 deletions src/admin/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# from wagtail.admin import urls as wagtailadmin_urls
# from django.conf.urls import include, url

# urlpatterns = [
# url(r'', include(wagtailadmin_urls)),
# ]

from django.contrib import admin
from django.urls import path

urlpatterns = [
path('', admin.site.urls),
]
5 changes: 5 additions & 0 deletions src/moore/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
'captcha',
'jsonschemaform',
'django_select2', # Custom select2 widget
'django_hosts', # Subdomains for admin site

'django.contrib.admin', # Used for wagtail admin filters
'django.contrib.auth',
Expand All @@ -79,6 +80,7 @@
]

MIDDLEWARE = [
'django_hosts.middleware.HostsRequestMiddleware', # Needed django_hosts
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand All @@ -89,6 +91,7 @@
'django.middleware.locale.LocaleMiddleware',

'wagtail.contrib.redirects.middleware.RedirectMiddleware',
'django_hosts.middleware.HostsResponseMiddleware', # Needed django_hosts
]

DATABASES = {
Expand All @@ -103,6 +106,8 @@
}

ROOT_URLCONF = 'moore.urls'
ROOT_HOSTCONF = 'moore.settings.hosts'


TEMPLATES = [
{
Expand Down
2 changes: 2 additions & 0 deletions src/moore/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
# backend - e.g. in notification emails. Don't include '/admin' or a
# trailing slash
BASE_URL = 'http://localhost:8000'
DEFAULT_HOST = 'www'

ALLOWED_HOSTS = ['admin.localhost', 'localhost']
# Email
# https://docs.djangoproject.com/en/1.10/ref/settings/#email-backend

Expand Down
8 changes: 8 additions & 0 deletions src/moore/settings/hosts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django_hosts import patterns, host
from django.conf import settings

host_patterns = patterns(
'',
host(r'www', settings.ROOT_URLCONF, name='www'),
host(r'admin', 'admin.urls', name='admin'),
)

0 comments on commit 94cbffc

Please sign in to comment.