Soft Deletes and a Trash View with FastAPI & starlette-admin
A standard DELETE operation is unforgiving. If an operator misclicks or an automated cleanup job runs against the wrong filter, the data is gone unless you perform a complex database restore. Implementing a "soft delete" mitigates this risk by flagging a record as deleted instead of permanently removing it from the database. This approach turns data recovery into a simple update operation.
This guide demonstrates how to implement the soft delete pattern in a FastAPI application using starlette-admin. We will build a complete solution utilizing:
- A single database model
- Two distinct administrative views
- A
deleted_attimestamp - A dedicated Trash interface for restoring or permanently purging records
View the complete runnable code: examples/advanced/01-soft-delete.