An admin panel for the SQLAlchemy 2.0 ORM that works with FastAPI, Starlette and Litestar.
Live demo · Documentation · Changelog · Discussions · For AI assistants
pip install adminsite
Add the driver your database needs, such as asyncpg or aiosqlite.
from adminsite import Admin, Link, ModelView
class OrderView(ModelView[Order]):
fields = [Order.id, Order.customer, Order.status, Order.total]
searchable_fields = [
Link(Order.customer, Customer.name),
Link(Order.customer, Customer.email),
]
list_filters = [Order.status, Order.created_at]
app.mount("/admin", Admin(engine, views=[OrderView]))The settings name your models' own attributes, so a type checker catches a misspelt one. The labels, filters, form controls and validation come from your models. Getting started builds a working admin in one file.
- Lists with search, sorting, saved views, editing in the list and auto refresh.
- Filters for text, numbers, dates, choices and related records, plus custom filters.
- Forms and record pages laid out in panels, rows and tabs.
- Related records picked from a searchable list, and child rows edited inside the parent's form.
- JSON columns edited as a form built from a Pydantic model or a TypedDict.
- File and image uploads, stored on disk or wherever you choose.
- Custom actions on the selected rows, every row the filters match, one record or the whole table.
- Hooks that run in the same transaction as a save or delete, and can refuse it.
- Permissions for each model, action, field and row.
- Built-in sign in, with users from your own user table.
- Users and roles managed in the admin, each role a grid of what it may do.
- Audit log of who changed what and when, with a history on every record.
- Import from CSV or Excel with a preview, and export to CSV.
- JSON API with the same permissions as the pages.
- Dashboard, Ctrl K search and custom pages.
- Light and dark themes, compact mode and a mobile layout.
- Keyboard and screen reader support.
- Translations into eleven languages, some right to left, and times in each reader's time zone.
- Async or sync engines on SQLite, Postgres and MySQL, with no N+1 queries.
- SQLModel models work too.
- Fast on large tables: counts can be estimated or skipped, and page 400 loads as fast as page 1.
- No Node and no CDN: everything ships inside the package.
Our business ran its back office on sqladmin, and then on starlette-admin. We needed features neither had, and in the end I had changed starlette-admin so much that turning it into pull requests would have taken more time than I had. So I built adminsite on what we learned from both, with everything our team needs.
It is not a side project. Our back office runs on it every day, and I keep developing it. An admin panel is not what sets our business apart, so it is open source, for anyone to use and improve.
adminsite is for SQLAlchemy only, and will stay that way. SQLModel models work too, since they are SQLAlchemy models, but I do not use SQLModel myself. If you do, reports and fixes are welcome.
- Getting started builds a working admin in one file.
- Views covers everything a view can say about a model.
- Permissions is worth reading before you put the admin in front of anyone.
- The reference lists every class and option.
Ask a question or share an idea in Discussions. Issues and pull requests are welcome. CONTRIBUTING.md says how to run the tests and rebuild the stylesheet.
