Exemple #1
0
def post_news():
    form = PostNewsForm()
    if form.validate_on_submit():
        news = News()
        news.body = form.body.data
        news.private = form.private.data
        news.title = form.title.data
        news.user_id = current_user.id
        db.session.add(news)
        db.session.commit()
        return redirect(url_for('.all_news'))
    return render_template('main/post_news.html', form=form)
Exemple #2
0
def post_news():
    form = PostNewsForm()
    if form.validate_on_submit():
        print('1')
        new = News()
        new.body = form.body.data
        new.private = form.private.data
        new.title = form.title.data
        new.user_id = current_user.id
        db.session.add(new)
        db.session.commit()
        print('2')
        return redirect(url_for('main.user_info', id=current_user.id))
    return render_template('main/post_news.html', form=form)