How Redirect Login.html To Chat.html Page After Successful Logged In Django Framework?
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 views.py file or from login.html?
Any help highly appreciated.
Django implements multiple ways to do this:
This is a global setting in your
settings.py. It works for all login pages when
next= parameter is not specified in login url (e.g.
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"> ... </form>
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.
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → laravel blade templating error
- → should I choose reactjs+f7 or f7+vue.js?
- → How to dynamically add class to parent div of focused input field?
- → Setting the maxlength of text in an element that is displayed
- → Expanding search bar not expanding before search
- → Get the calling element with vue.js
- → Blade: how to include a section in one page but not in another
- → How to print/log reactjs rendered dom?
- → how to write react component to construct HTML DOM