def store_detail(store_id): store = GroceryStore.query.get(store_id) form = GroceryStoreForm(obj=store) if form.validate_on_submit(): form.populate_obj(store) db.session.add(store) db.session.commit() flash("Store was successfully updated.") return redirect(url_for('main.store_detail', store_id=store.id)) return render_template('store_detail.html', store=store, form=form)
def store_detail(store_id): store = GroceryStore.query.get(store_id) form = GroceryStoreForm(obj=store) # If form was submitted and was valid: if form.validate_on_submit(): # Populates the attributes of the passed obj with data from the form's fields form.populate_obj(store) db.session.add(store) db.session.commit() flash('Store was edited successfully.') return redirect(url_for('main.store_detail', store_id=store.id)) store = GroceryStore.query.get(store_id) return render_template('store_detail.html', store=store, form=form)