Home

Awesome

starlette-admin

Fast, beautiful, and extensible administrative interface framework for Starlette & FastApi applications

<p align="center"> <a href="https://github.com/jowilf/starlette-admin/actions/workflows/test.yml"> <img src="https://github.com/jowilf/starlette-admin/actions/workflows/test.yml/badge.svg" alt="Test suite"> </a> <a href="https://github.com/jowilf/starlette-admin/actions"> <img src="https://github.com/jowilf/starlette-admin/actions/workflows/publish.yml/badge.svg" alt="Publish"> </a> <a href="https://codecov.io/gh/jowilf/starlette-admin"> <img src="https://codecov.io/gh/jowilf/starlette-admin/branch/main/graph/badge.svg" alt="Codecov"> </a> <a href="https://pypi.org/project/starlette-admin/"> <img src="https://badge.fury.io/py/starlette-admin.svg" alt="Package version"> </a> <a href="https://pypi.org/project/starlette-admin/"> <img src="https://img.shields.io/pypi/pyversions/starlette-admin?color=2334D058" alt="Supported Python versions"> </a> </p>

Preview image

why starlette-admin?

FastAPI has emerged as a popular web framework for building APIs in Python. However, it lacks a mature admin interface solution like Flask-Admin to quickly manage your data through a user-friendly interface. Although solutions like Sqladmin and Fastapi-Admin exist, they only work with specific ORMs such as SQLAlchemy and Tortoise ORM.

Starlette-admin was born from the need for a FastAPI admin interface that works with various data layer. It aims to provide a complete solution for CRUD interfaces regardless of the database backend. Starlette-admin works out of the box with multiple ORM/ODMs and can also be used with a custom data layer.

Getting started

Features

Installation

PIP

$ pip install starlette-admin

Poetry

$ poetry add starlette-admin

Example

This is a simple example with SQLAlchemy model

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Mapped, mapped_column
from starlette.applications import Starlette

from starlette_admin.contrib.sqla import Admin, ModelView

Base = declarative_base()
engine = create_engine("sqlite:///test.db", connect_args={"check_same_thread": False})


# Define your model
class Post(Base):
    __tablename__ = "posts"

    id: Mapped[int] = mapped_column(primary_key=True)
    title: Mapped[str]


Base.metadata.create_all(engine)

app = Starlette()  # FastAPI()

# Create admin
admin = Admin(engine, title="Example: SQLAlchemy")

# Add view
admin.add_view(ModelView(Post))

# Mount admin to your app
admin.mount_to(app)

Access your admin interface in your browser at http://localhost:8000/admin

Third party

starlette-admin is built with other open source projects:

Contributing

Contributions are welcome and greatly appreciated! Before getting started, please read our contribution guidelines