Reputation: 147
Hai so i am trying to increase a number ( +1 ) in my join column on button click on flask so far i done up to this
@app.route("/joins/<name>", methods=["POST"])
def joins(name):
namess = name
owner = users.query.filter_by(name=namess).first()
if owner is not None:
#making the joins +1 if the value is already 1
owner.joins = + 1
db.session.commit()
return redirect("/")
else:
return "You are not the owner of this url"
but it is not increasing the number how can i fix this happy coding!
Upvotes: 0
Views: 317
Reputation: 592
The line
owner.joins = + 1
is valid python but I don't think it's what you want. It just assigns 1 to owner.joins
. If you want to increment you need to do it like this:
owner.joins = owner.joins + 1
Upvotes: 1