def publish_article(): if request.method == 'POST': title = request.form.get('title') type_id = request.form.get('type') content = request.form.get('content') article = Article() article.title = title article.type_id = type_id article.content = content article.user_id = g.user.id db.session.add(article) db.session.commit() return redirect(url_for('user.index'))
def publish_article(): if request.method == 'POST': title = request.form.get('title') content = request.form.get('content') uid = request.form.get('uid') # 添加文章 article = Article() article.title = title article.content = content article.user_id = uid db.session.add(article) db.session.commit() return '添加成功!' else: users = User.query.filter(User.isdelete == False).all() return render_template('article/add_article.html', users=users)
def publish_article(): if request.method == 'POST': title = request.form.get('title') type_id = request.form.get('type') content = request.form.get('content') # print(title) # print(type_id) # print(content) # print(g.user.id) # 添加文章 article = Article() article.title = title article.content = content article.type_id = type_id # article.user_id = g.user.id # db.session.add(article) db.session.commit() # return '发表成功!' return redirect(url_for('user.index'))