In urls.py I have:
path('/admin/', admin.site.urls),
path('/admin/login', login_required(admin.site.login)),
path('/customlogin/', include('customlogin.urls', namespace='customlogin'))
This redirects to a custom authentication view, specified in settings.LOGIN_URL
.
When you go to /admin
it redirects to /admin/login/?next=/admin
, which does not redirect to LOGIN_URL
. But when you go to /admin/login
directly, everything works correctly.
Note: This worked correctly in Django 1.11.
To match the admin login url, your path should have a trailing slash. You also have to move your path above admin.site.urls
, so that Django uses your decorated view.
path('/admin/login/', login_required(admin.site.login))
path('/admin/', admin.site.urls),