Exemplo n.º 1
0
def new_post():
    form = PostForm()

    if form.validate_on_submit():
        new_post = Post(form.title.data)
        new_post.body = form.text.data
        new_post.publish_time = datetime.datetime.now()
        new_post.user = current_user
        db.session.add(new_post)
        db.session.commit()

    return render_template('new.html', form=form)