O'Reilly logo

Instant Flask Web Development by Ron DuPlain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Editing a record (Intermediate)

Now we provide an edit page for existing appointments, as shown in the following screenshot:

Editing a record (Intermediate)

Getting ready

We will continue to work from the app.py file from the sched directory and templates directory.

How to do it...

  1. The edit workflow is a mix of add and detail views. We get an appointment, and if it exists, we display a form to edit it. In app.py:
    @app.route('/appointments/ <int:appointment_id>/edit/, methods=['GET', 'POST']) def appointment_edit(appointment_id): """Provide HTML form to edit a given appointment.""" appt = db.session.query(Appointment).get(appointment_id) if appt is None: abort(404) form = AppointmentForm(request.form, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required