When i logged in flash message is not displayed.How can i fix it ?
My login def is below
@app.route("/login",methods=["GET","POST"])
def login():
form=LoginForm(request.form)
if request.method=="POST":
username=form.username.data
password_entered=form.password.data
cursor=mysql.connection.cursor()
sorgu="Select * From users where username = %s"
result=cursor.execute(sorgu,(username,))
if result>0:
data=cursor.fetchone()
real_password=data["password"]
if sha256_crypt.verify(password_entered,real_password):
flash("Başarıyla giriş yaptınız...","info")
session["logged_in"]=True
session["username"]=username
return redirect(url_for("index"))
else:
flash(("wrong password","warning"))
return redirect(url_for("login"))
else:
flash("this username is not avaible","warning")
return render_template("login.html",form=form)
i dont know why it is not working.When logged in redirect url function is working but flash message does not appear.
You're passing in one argument (a tuple) instead of two.
Change flash(("wrong password","warning"))
to flash("wrong password","warning")