def user_account(): """ Fetch and update user account """ form = UserProfileForm(request.form, current_user) if request.method == 'POST' and form.validate(): form.populate_obj(current_user) db.session.commit() return redirect(url_for('home.index')) return render_template( 'user/account.html', form=form)
def user_profile_page(): # Initialize form form = UserProfileForm(request.form, current_user) # Process valid POST if request.method == 'POST' and form.validate(): # Copy form fields to user_profile fields form.populate_obj(current_user) # Save user_profile db.session.commit() # Redirect to home page return redirect(url_for('core.home_page')) # Process GET or invalid POST return render_template('core/user_profile_page.html', form=form)