Flask编辑配置文件页面未渲染

时间:2018-07-18 13:40:28

标签: python flask

我正在构建Flask应用程序,无论出于何种原因,我都无法加载我的Edit-Profile表单。我没有收到错误,只是得到了一个空白屏幕。任何帮助,我们将不胜感激。

在这里,我的模型。py:

class User(db.Model): 
    __tablename__ = 'users'
    __table_args__ = {'extend_existing': True} 
    id = db.Column(db.Integer, primary_key = True)
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), unique=True, index=True)
    password_hash = db.Column(db.String(128))
    #confirmation_code = db.Column(db.Sting(200))

    role_id = db.Column(db.Integer, db.ForeignKey('roles.id')) 
    confirmed = db.Column(db.Boolean, default=False)

    posts = db.relationship('Post', backref='author', lazy='dynamic') 
    comments = db.relationship('Comment', backref='author', 
    lazy='dynamic') 

    name = db.Column(db.String(64))
    location = db.Column(db.String(64))
    about_me = db.Column(db.Text())
    member_since = db.Column(db.DateTime(), default=datetime.utcnow)
    last_seen = db.Column(db.DateTime(), default=datetime.utcnow)
    avatar_hash = db.Column(db.String(32))

这是我的观点。py

@server.route('/edit-profile', methods=['GET', 'POST'])
@login_required
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        db.session.add(user)
        flash('Your Profile Has Been Updated')
        return redirect(url_for('user', username=current_user.username))
    form.name.data = current_user.name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form) 

这是我的Forms.py

class EditProfileForm(Form): 
    name = StringField('Real Name', validators=[Length(0, 64)])
    location = StringField('Location', validators=[Length(0, 64)])
    about_me = TextAreaField('About Me')
    submit = SubmitField('Submit')
    #photo = FileField()

已编辑-这是edit_profile.html

{% extends "base.html" %}

{% import "bootstrap/wtf.html" as wtf %} 

{% block title %} Deplorable Snowflake- Edit Profile {% endblock %}

{% block page_content %} 

<div>

<h1> Edit Your Profile </h1>

{{wtf.quick_form(form)}}

</div>



{% endblock %} 

再次感谢

0 个答案:

没有答案