From the course: Flask Essential Training
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Update and delete operations
From the course: Flask Essential Training
Update and delete operations
- [Instructor] Let's build on our simple form example. We'll add functionality to update and delete users directly from the user's list page and save these changes in the database. And to keep things simple, we'll add both update and delete functionality directly on the user list page. That is users template. We're working in app.py, and we're making changes to the user's route. To this route we will add two methods. Get and post method. The user's route now handles both get and post requests. For get requests, it displays the list of users and for post requests, it updates the user's email. When a post request is received, it means the user submitted the update form. This line of code retrieves the user ID from the form data. Then, we retrieve the user email, the new email from the form. Then we find the user in the database by their id. Then we check if the user exists. We update the user's email, we save the changes. And when get request is received, that means user is visiting the…
Contents
-
-
-
-
-
-
-
-
(Locked)
Setting up SQLAlchemy5m 35s
-
(Locked)
Model creation1m 55s
-
(Locked)
Conceptual overview of create and read2m 29s
-
(Locked)
Create and read operations6m 26s
-
(Locked)
Conceptual overview of update and delete1m 44s
-
(Locked)
Update and delete operations3m 24s
-
(Locked)
Project step 7: Integrating the SQLite database with Flask2m 46s
-
(Locked)
Project step 8: Implementing create and read operations3m 25s
-
(Locked)
-
-
-