关于flask新建文章跳转的问题?

我想要实现新建文章后跳转到文章一直不成功? 以下是代码:

@main.route('/create-post', methods=['GET', 'POST'])

@login_required

def create_post():

`form = PostForm()

if current_user.can(Permission.WRITE_ARTICLES) and \

        form.validate_on_submit():

    post = Post(post_title=form.post_title.data,

                body=form.body.data,

                author=current_user._get_current_object())

    db.session.add(post)

    return redirect(url_for('.post', id=post.id))

return render_template('create_post.html', form=form, title=u'创建新文章')`
9 comments