Build admin interfaces for FastAPI applications using FastUI and SQLAlchemy.
Inspired by Flask-Admin and SQLAdmin.
Note: FastUI Admin is an active work in progress. The API may change as the project matures alongside FastUI.
- Automatic CRUD interface for SQLAlchemy models
- List view with pagination
- Detail, create, edit, and delete views
- Auto-generated forms from model columns
- Navigation bar with registered model views
- Configurable columns, page size, and permissions
- Mounts as a sub-application on FastAPI or Starlette
pip install fastui-adminFor async SQLite support (used in examples):
pip install aiosqlite greenletfrom fastapi import FastAPI
from sqlalchemy import Boolean, Integer, String
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from fastui_admin import BaseAdmin, BaseModelView
# Define your models
class Base(DeclarativeBase):
pass
class User(Base):
__tablename__ = "users"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
username: Mapped[str] = mapped_column(String(50), unique=True)
email: Mapped[str] = mapped_column(String(100))
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
# Define admin views
class UserAdmin(BaseModelView, model=User):
name = "Users"
column_list = ["id", "username", "email", "is_active"]
page_size = 25
# Set up the app
app = FastAPI()
engine = create_async_engine("sqlite+aiosqlite:///./db.sqlite3")
admin = BaseAdmin(app, engine, title="My Admin")
admin.add_view(UserAdmin)
admin.mount()Run the app and visit http://localhost:8000/admin/.
| Parameter | Type | Default | Description |
|---|---|---|---|
app |
FastAPI | Starlette |
required | Application to mount admin on |
engine |
Engine | AsyncEngine |
None |
SQLAlchemy engine |
session_maker |
sessionmaker | async_sessionmaker |
None |
Custom session maker |
title |
str |
"Admin" |
Admin interface title |
base_url |
str |
"/admin" |
Base URL path |
logo_url |
str |
None |
Logo image URL |
| Parameter | Type | Default | Description |
|---|---|---|---|
model |
class keyword | required | SQLAlchemy model class |
name |
str |
Model name | Display name |
column_list |
list[str] |
All columns | Columns to show in list view |
column_exclude_list |
list[str] |
[] |
Columns to exclude from list |
page_size |
int |
25 |
Items per page |
can_create |
bool |
True |
Enable create action |
can_edit |
bool |
True |
Enable edit action |
can_delete |
bool |
True |
Enable delete action |
can_view_details |
bool |
True |
Enable detail view |
See the examples/basic directory for a complete working example with User and Post models.
# Run the example
uvicorn examples.basic.main:app --port 5000
# Seed sample data
curl -X POST http://localhost:5000/seed
# Visit admin interface
open http://localhost:5000/admin/Comparison with Flask-Admin and SQLAdmin (ref: sqladmin#316).
| Feature | Flask-Admin | SQLAdmin | FastUI Admin |
|---|---|---|---|
| ModelView | ✅ | ✅ | ✅ |
| BaseView (custom pages) | ✅ | ❌ | ✅ |
| Authentication | ✅ | ✅ | ❌ |
| Ajax / search | ✅ | ❌ | ❌ |
| Custom templates | ✅ | ✅ | ❌ |
| Batch actions | ✅ | ❌ | ❌ |
| Inline models | ✅ | ❌ | ❌ |
| Export (CSV, etc.) | ✅ | ✅ | ❌ |
| File/image upload | ✅ | ✅ | ❌ |
| I18n | ✅ | ❌ | ❌ |
| Async support | ❌ | ✅ | ✅ |
| Option | Flask-Admin | SQLAdmin | FastUI Admin |
|---|---|---|---|
can_create |
✅ | ✅ | ✅ |
can_edit |
✅ | ✅ | ✅ |
can_delete |
✅ | ✅ | ✅ |
can_view_details |
✅ | ✅ | ✅ |
can_export |
✅ | ✅ | ❌ |
column_list |
✅ | ✅ | ✅ |
column_exclude_list |
✅ | ✅ | ✅ |
column_formatters |
✅ | ✅ | ❌ |
column_searchable_list |
✅ | ✅ | ❌ |
column_sortable_list |
✅ | ✅ | ❌ |
column_default_sort |
✅ | ✅ | ❌ |
column_labels |
✅ | ✅ | ❌ |
page_size |
✅ | ✅ | ✅ |
form_include_pk |
✅ | ✅ | ❌ |
form_columns |
✅ | ✅ | ❌ |
form_excluded_columns |
✅ | ✅ | ❌ |
form_widget_args |
✅ | ✅ | ❌ |
form_args |
✅ | ✅ | ❌ |
See ROADMAP.md for the full feature roadmap, including planned support for column sorting, search/filtering, authentication, export, and more.
- FastUI - Build web UIs with declarative Python
- FastUI Tutorials - Learning resource for FastUI
- SQLAdmin - Admin interface for SQLAlchemy (Jinja2-based)
- Flask-Admin - Admin interface for Flask
Vibe coded by Claude Opus 4.5, reviewed and tested by @hasansezertasan.
fastui-admin is distributed under the terms of the MIT license.
0 comments
log in to comment.