I
israel wonah
Guest
israel wonah Asks: please i want to add categories to my blog using python and flask
this are some files in my main.py I have two section in my blog, so I want each post to appear on it's selected category on view
I Have created the categories column in the database and forms.py, I want the added post to appear on the categories sections on view.
this are some files in my main.py I have two section in my blog, so I want each post to appear on it's selected category on view
Code:
@app.route("/post/<int:post_id>", methods=["GET", "POST"])
def show_post(post_id):
comment_form = CommentForm()
requested_post = BlogPost.query.get(post_id)
if comment_form.validate_on_submit():
if not current_user.is_authenticated:
flash("You need to login before you comment bro")
return redirect(url_for('login'))
new_comment = Comment(
text=comment_form.comment_text.data,
comment_author=current_user,
parent_post=requested_post
)
db.session.add(new_comment)
db.session.commit()
comment_form.comment_text.data = ""
return render_template("post.html", post=requested_post, current_user=current_user, form=comment_form)
I Have created the categories column in the database and forms.py, I want the added post to appear on the categories sections on view.