M main/middleware.py => main/middleware.py +5 -1
@@ 39,8 39,12 @@ def host_middleware(get_response):
# * also validation will happen inside views
request.subdomain = host_parts[0]
+ allow_docs_user = False
+ if request.subdomain == "docs" and settings.ALLOW_DOCS_USER:
+ allow_docs_user = True
+
# check if subdomain is disallowed
- if request.subdomain in denylist.DISALLOWED_USERNAMES:
+ if request.subdomain in denylist.DISALLOWED_USERNAMES and not allow_docs_user:
return redirect(f"{util.get_protocol()}//{settings.CANONICAL_HOST}")
# check if subdomain exists as blog
elif models.User.objects.filter(username=request.subdomain).exists():
M mataroa/settings.py => mataroa/settings.py +2 -0
@@ 31,6 31,8 @@ DEBUG = os.getenv("DEBUG") == "1"
LOCALDEV = os.getenv("LOCALDEV") == "1"
+ALLOW_DOCS_USER = os.getenv("ALLOW_DOCS_USER", "0") == "1"
+
ALLOWED_HOSTS = [
"127.0.0.1",
"localhost",