Skip to content

adminsite

An admin panel for SQLAlchemy models. Mount it into Starlette, FastAPI or Litestar, and your team gets pages to search, filter, read and change your data.

The orders list of the demo shop

from adminsite import Admin, Descending, Link, ModelView


class OrderView(ModelView[Order]):
    fields = [Order.id, Order.customer, Order.status, Order.total, Order.created_at]
    searchable_fields = [
        Order.id,
        Link(Order.customer, Customer.name),
        Link(Order.customer, Customer.email),
    ]
    list_filters = [Order.status, Order.total, Order.created_at]
    fields_default_sort = [Descending(Order.created_at)]


admin = Admin(engine, title="Acme", views=[OrderView])
app.mount("/admin", admin)

That is a working admin. The settings name your models' own attributes, so a type checker catches a misspelt one before you run anything. The labels, filters, form controls and validation all come from your models.

Try it

The live demo runs the example shop, and a Field gallery with every kind of field. Sign in as admin with the password admin and change anything you like. You get a copy of your own, so only you see what you change.

What you get

  • Pages worked out from your models. Column types pick the right controls, created_at reads "Created at", an enum becomes a select, and a foreign key becomes a picker for the record it points at.
  • No N+1 queries. Showing an order's customer loads the customers with the page. Tests count the statements so it stays that way.
  • Fast on large tables. Counting can be switched off per view, which makes a page one query.
  • Filters you can write yourself, next to the built-in ones.
  • Bulk actions over everything that matches, not only the rows on the page, and actions that ask for values first.
  • Permissions at four levels: the view, the action, the field and the row.
  • Hooks inside the transaction that can read other tables and refuse a save.
  • An audit log with a history on every record.
  • Async or sync. An AsyncEngine or a plain Engine both work. Tested on SQLite, Postgres and MySQL.
  • No Node and no CDN. The CSS and JavaScript ship inside the package.

Where to go next

  • Getting started builds a working admin in one file.
  • Views covers everything a ModelView can say about a model.
  • Permissions is worth reading before you put the admin in front of anyone.

For AI assistants

If an AI assistant helps you build with adminsite, point it at llms.txt, a short guide with links to every page, or llms-full.txt, the whole documentation in one file. Both are rebuilt with the docs for each release.