I am making a custom administration page in Django. I do not want to reinvent the wheel and thus want to use Django admin login form for the staff to log in and redirect them to /my-url/ afterwards.
However, I can't find the way to redirect user to a custom url after successful login at /admin/.
I had the same issue. Instead of redirect after login I used the @staff_member_required decorator for my view
/my-url/
which redirects to the admin loginIf class based views is used check out the method_decorator
since I stumbled across the same problem, I noticed the url of the the default login page:
so I changed the login page link to
to point to the main page
works for the logout page too, nice and simple
Set
LOGIN_REDIRECT_URL
in yoursettings.py
file. Documented here.The Django auth app comes with a login view which you can hook up to
/accounts/login/
or any other url you choose. You can probably use the admin's login templateadmin/login.html
if you don't want to write your own.By using the login view, the
LOGIN_REDIRECT_URL
parameter will work. The purpose of the/admin/
page is to display the admin index. I would avoid trying to use it as the login page.