How to get the result of a specific request on the same page in django? For example, if my "index.html" has a form with two fields for username and password. In views.py, I check if the values match the fields in db or not. I want to return the string "Login successfull" or "Login Failed" on the same page. Suggest the code you need for views.py and index.html. I am currently checking the values and creating a new page. Please suggest how to return it on the same page. Thanks in advance!
def index(request):
return render(request, "index.html")
def stage2(request):
if Verify.objects.filter(usr=request.POST['us'],password=request.POST['pass'])
request.session['usr']=request.POST['us']
a=request.session['usr']
dict1={'u':a}
return render(request,"success.html",dict1)
else:
return render(request,"failed.html")
I want to show the result on the same page ie "index.html"
source
share