def add_post(): form = PostForm() if form.validate_on_submit(): post = Post(title=form.title.data, content=form.content.data) post.slug_(str(form.title.data)) db.session.add(post) db.session.commit() return redirect(url_for('index')) return render_template('add_post.html', form=form)