烧瓶应用程序中的jinja2.exceptions.UndefinedError

时间:2020-07-17 23:39:21

标签: python flask

我有一个烧瓶应用程序,但是我在某个地方出错了

这是我收到的错误消息

jinja2.exceptions.UndefinedError: 'flaskblog.forms.PostForm object' has no attribute 'title'

它说我在149行的routes.py文件中有一个错误

这是此文件的内容

@app.route("/post/new", methods=['GET', 'POST'])
@login_required
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data, content=form.content.data, author=current_user)
        db.session.add(post)
        db.session.commit()
        flash('Your post has been created!', 'success')
        return redirect(url_for('home'))
    return render_template('create_post.html', title='New Post',
                           form=form)

form=form)在第149行

除此之外,我也得到那些错误 enter image description here

那些是有问题的文件-我将其粘贴到pastebin上: 这是create_post.html https://pastebin.com/06JWf87K 这是layout.html enter link description here

0 个答案:

没有答案