Skip to content

FastAPI

Add an Admin Panel to FastAPI in 5 Minutes with starlette-admin

Your backend is up and running, but non-engineers soon need to modify live data. Someone has to fix a typo in a record, unpublish a post, or inspect a user submission. The standard workarounds are rarely clean:

Option The Drawback
Custom CRUD Frontend Takes weeks of developer time to build and maintain.
Raw Database Access Creates a massive security and data integrity liability.
Django Admin / Flask Admin Forces a framework rewrite or relies on synchronous WSGI, which blocks your asynchronous ASGI application.
starlette-admin Mounts to your app instantly with zero frontend code.

starlette-admin works with any Starlette-based application, which is exactly what FastAPI is.

This guide takes you from an empty file to a working back office in five minutes. You will build paginated lists, search functionality, sortable columns, create and edit forms validated by your existing Pydantic schemas, deletion confirmations, and CSV exports, all generated directly from a SQLAlchemy model.

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_at timestamp
  • A dedicated Trash interface for restoring or permanently purging records

View the complete runnable code: examples/advanced/01-soft-delete.