How Redirect Login.html To Chat.html Page After Successful Logged In Django Framework?

- 1 answer

I have used template/login.html for logging in, after successful logged in how to redirect the login.html page to chatwindow.html page (some other html) in Django framework.

So, do I need to redirect it from file or from login.html?

Any help highly appreciated.



Django implements multiple ways to do this:


This is a global setting in your It works for all login pages when next= parameter is not specified in login url (e.g.

2. Use next parameter in the login URL

This is usually used to customize the login redirect for individual cases.

The common use-case is when you use @login_required decorator. When a user tries to access a page which requires authentication, a user is then redirected to a login page with a next= parameter pointing to the current page. For example if the user went to /secure/page, then the login page will be something like /login?next=/secure/page. After the user will successfully authenticate, Django will redirect them back to the protected page.

3. Use the hidden input next on the login page

Finally you can set the redirect path in the login form itself:

<form method="POST" ...>
    <input typy="hidden" name="next" value="/secure/page">

I would guess that first method might be the most appropriate in your case however keep in mind the other options if you will need them.