django template tag - comparing two variables -


{% if firstpass != secondpass %}         errors.append('passwords not same') 

i trying make page users can change personal information. 1 in particular pertains checking whether password textbox (firstpass) , password re-entering textbox (secondpass) contain same password. reason, getting compiler error on line != sign. can suggest why? : (

if taught right need append error message errors list. need change bit.

first need create form in template. create dummy form understand happening.

<form action="/password-confirm/" method="post">{% csrf_token %}   <input type="text" name="firstpass">   <input type="text" name="secondpass">   <input type="submit" name=""> </form> 

second create view in views.py.

def password_confirm(request):     if request.method == "post":         firstpass = request.post["firstpass"]         secondpass = request.post["secondpass"]         if firstpass == secondpass:             // write code if passwords same.         else:             errors.append("passwords not same")     return render(request, 'password_confirm.html') 

third in urls.py.

url(r'^password-confirm/$', 'happytenants.views.password_confirm', name='about_us'), 

and if need display error in template, pass variable template.

def password_confirm(request):     ...     return render(request, 'password_confirm.html', {"errors": errors}) 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -