<form method="post" action="/" class="mb-2">
{% csrf_token %}
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Enter Your Username" Required>
</div>
<div class="form-group">
<label for="pass1">Password</label>
<input type="password" class="form-control" id="pass1" name="pass1" placeholder="Enter Your Password" Required>
</div>
<button type="submit" class="btn btn-primary">Log In</button>
</form>
This is the form from home.html
def home(request):
if request.method == 'POST':
username = request.POST.get('username')
pass1 = request.POST.get('pass1')
user = authenticate(username=username, pass1=pass1)
if user is not None:
login(request, user)
return render(request,"main_tem/room.html")
else:
return redirect('signup')
return render(request,"main_tem/home.html")
this is home view from views.py in 'main' app.
so as u can see from the home view if user is present or signuped it should redirect user to room.html page but when i try to do it it redirects to signup page which shouldnt happen if user is already present in data base. i am kind of lost here as i dont know what kind of solution i should search for. from what i have observed i think home view is not able to get data from the form in home.html
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns=[
path("",views.home,name="home"),
path("signup",views.signup,name="signup"),
path("rooms",views.rooms,name="rooms"),
]
for reference here is the urls.py from 'main' app