I want my user to be redirected to the last page after successfully logging in. But the user is redirected to the index page
this is what I've in my header
<li><a href="/login">Login</a></li>
here is the login form
<form method="post" action="{% url 'django.contrib.auth.views.login' %}" >
{% if form.errors %}
<p>Your username and password don't match our records. Please try again.</p>
{% endif %}
<div class="login">
<h1> LOG IN </h1>
<input type="text" class="form-control" id="username" placeholder="Email" name="username">
<input type="password" class="form-control" id="inputPassword" placeholder="Password" name="password">
<button class="btn btn-primary" type="submit" name="submit" id="ss-submit">LOG IN</button>
<input type="hidden" name="next" value="{{ next }}" />
<!-- <a href="/forgotpassword">Forgot your password?</a> -->
<p>Don't have an account? <a href="/signup">Sign up</a></p>
</div>
<!-- End Log In -->
{% csrf_token %}
</form>
Here is the login
url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'meddy1/login.html'}, name="login"),
here is a template
def dentists(request):
d = getVariables(request)
doctors = Doctor.objects.all().order_by('-likes')
paginator = Paginator(doctors, 20) #Show 20 doctors per page
page = page = request.GET.get('page')
try:
doctors = paginator.page(page)
except PageNotAnInteger:
doctors = paginator.page(1)
except EmptyPage:
doctors = paginator.page(paginator.num_pages)
d['doctors'] = doctors
d['paginator'] = paginator
return render_to_response('meddy1/dentists.html',d)