1👍
I’ve taken a look at your code.
That’s not the redirect problem.
That’s because of submit url of the login form.
You should change the code like below.
<form action = '/accounts/login' method = 'post'>
{% csrf_token %}
<input type="text" name="username" placeholder="Username"><br>
<input type="password" name="password" placeholder="Password"><br>
<input type = 'submit'>
</form>
In addition, When check the authentication, you should check user, not username.
if user is not None:
auth.login(request, user)
return redirect('/')
else:
return redirect('/accounts/register/')
👤Adam
Source:stackexchange.com