Wait db connection, login required, dev mode enable

This commit is contained in:
Luciano Gervasoni
2025-04-04 12:28:22 +02:00
parent 4dbe2e55ef
commit 76079d7bd0
8 changed files with 105 additions and 54 deletions

View File

@@ -0,0 +1,24 @@
from django.shortcuts import redirect
from django.conf import settings
from django.urls import reverse
EXEMPT_URLS = [
# reverse('login'), # or the name of your login view
reverse('admin:login'),
reverse('admin:index'),
# reverse('logout'), # optional
'/admin/', # allow full access to admin
settings.STATIC_URL, # allow static files
# path('scheduler/', include('scheduler.urls')),
]
class LoginRequiredMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
if not request.user.is_authenticated:
path = request.path
if not any(path.startswith(url) for url in EXEMPT_URLS):
return redirect(settings.LOGIN_URL)
return self.get_response(request)