I read this.
Django: Redirect to previous page after login
But in my case it doesn't work. Also in my settings.py, I have
LOGIN_REDIRECT_URL = '/home' #it means the home view
I have done this in my base.html
<li><a href="{% url django.contrib.auth.views.login %}?next={{request.path}}">Patient's login</a></li>
and also have added this to my login.html
<input type="hidden" name="next" value="{{ next }}" />
But still it doesn't redirect to the page the user was after login. Also when the user is logged in, how can I show at the top right corner on the nav bar something like "Welcome #"
# being whatever the username is.
And when he's logged out, it doesn't show such thing. And I'm using an CustomUser(AbstractUser) in models.py
How can i do this?
login.html
<form action="{% url 'login' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<h1>Login Form</h1>
<div class="imgcontainer">
<img src="{% static 'student/patient.jpg' %}" alt="Avatar" class="avatar">
</div>
<div class="username">
{{ form.username.label_tag }}
{{ form.username }}
</div>
<div class="password">
{{ form.password.label_tag }}
{{ form.password }}
</div>
<div class="submitb">
<input type="submit" value="Log In" name="mybtn">
</div>
<div class="resetb">
<input type="submit" value="Reset">
<a href="#forgotpwd">Forgot password?</a>
</div>
<input type="hidden" name="next" value="{{ next }}" />
</form>