This is my login redirect url in settings.py:
LOGIN_REDIRECT_URL='/category/all'
And this is my login view:
def login(request):
if request.user.is_authenticated:
return redirect('/')
else:
if request.method == "POST":
email=request.POST['email']
password=request.POST['password']
user=auth.authenticate(email=email,password=password)
if user is not None:
auth.login(request, user)
return redirect('/')
else:
messages.info(request,"Email Password didn't match")
return redirect('login')
else:
return render(request,"login.html")
Whenever the user logs in I want to redirect him to the category/all page but it is always redirecting to index("/") and this might be because I am using return redirect("/").Also even when I have login required for some view then too even when the url is like:
http://localhost:8000/login/?next=/cart/
Instead of redirecting me to cart it redirects too index. Please help me to work around this so that the redirect works properly.