I need to pass the feature_id value when the request is POST. but I get a null value from the following code.
@app.route("/add_user_story", methods=["GET", "POST"])
@login_required
def add_user_story():
feature_id=request.args.get("feature_id")
print(feature_id)
if request.method == "POST":
user_story = User_stories(
user_id=session["user"],
feature_id =feature_id,
as_a=request.form.get("as_a"),
i_want=request.form.get("i_want"),
so_that=request.form.get("so_that"),
given=request.form.get("given"),
when=request.form.get("when"),
then=request.form.get("then")
)
db.session.add(user_story)
db.session.commit()
return render_template("logged_in/add_user_story.html")
I have checked the terminal and my print statement has the value so I know it getting that far, To test if the form works I have replaced feature_id =feature_id with feature_id =24, and it successfully posted the data.
I have also tried
# LOGGED IN - Add User Story
@app.route("/add_user_story", methods=["GET", "POST"])
@login_required
def add_user_story():
if request.method == "POST":
user_story = User_stories(
user_id=session["user"],
feature_id=request.args.get("feature_id"),
as_a=request.form.get("as_a"),
i_want=request.form.get("i_want"),
so_that=request.form.get("so_that"),
given=request.form.get("given"),
when=request.form.get("when"),
then=request.form.get("then")
)
db.session.add(user_story)
db.session.commit()
return render_template("logged_in/add_user_story.html")