People and Things example - tstorrnetnz/teaching2025 GitHub Wiki

People and Things

People and Things Github branch

The replit code has comments to help you understand what has been done, and how the code works. Some methods that you will find useful are:

  • edit_person - shows an example of redirecting to another page based on an if statement
  • update - shows how to update a record using SQLAlchemy, and also delete a record.

This is an example of using Flask and SQLAlchemy of some of the skills that you will need for your project. It is not an example project!

It demonstrates some very useful techniques:

  • Checking if the database exists
  • Creating people objects (from the people class) and adding them to the database using SQLAlchemy
  • The ability to edit a person once they have been created - by using a custom url for the person being created
  • The ability to delete a person

What has not been done (but should be OK to do):

  • Same for thing objects as people
  • Change the relationships between people and things
  • Validation of any data that is entered
  • Use of any images in the database

Screenshot from 2023-06-21 11-23-54

Selecting which person to edit.

Screenshot from 2023-06-21 11-24-29

The correct person is selected and details retrieved from the database. Any edited values will be saved (or the person deleted).

Screenshot from 2023-06-21 11-25-04

Displays a list of the people, to confirm the details have been changed.