I have a jinja template with 2 variables (one of them inside a for loop) and I want to pass them to a bootstrap modal in order to confirm a delete that is triggered within the loop. The schema of it is something like this:
<object_outside_loop>
<!-- Loop -->
{% for item_inside_loop in items %}
<button type="button" data-toggle="modal">Delete</button>
{% endfor %}
<!-- Modal -->
<my-modal-here>
<a href="{{ url_for('delete_something', id1=object_outside_loop._id, id2=item_inside_loop._id) }}" >Confirm Delete</a>
</my-modal-here>
and I need to pass both variables (id1 and id2) from the modal to my route:
@app.route("/delete_something/<id1>/<id2>")
def delete_something(id1, id2):
mongo.db.something.update_one(
{"_id": ObjectId(id2)},
{"$pull": {"something": {"_id": ObjectId(id1)}}},
)
flash("Your something has been updated!", "success")
return redirect(url_for("somewhere", id=id2))
How can I pass those two variables to the modal, and how do I do that without breaking the endpoint?