My index.html file shows all posts in a blog. The index.html file contains a part that allows the user to delete a certain post. Here is the html code
<p class="post-meta">Posted by
<a href="#"> {{ post.author.name }} </a>
on {{post.date}}
{% if current_user.id == post.author.id %}
<a href="{{url_for('delete_post', post_id=post.id) }}">✘</a>
{% endif %}
</p>
If '✘' is pressed following function in main will be called:
@app.route("/delete/<int:post_id>")
@admin_only
def delete_post(post_id):
post_to_delete = BlogPost.query.get(post_id)
db.session.delete(post_to_delete)
db.session.commit()
return redirect(url_for('get_all_posts'))
I would like to insert a message which asks the user if he really wants to delete the post and only when the user clicks 'yes' the post will be really deleted in the database. Can anybody help me?