0

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!

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.