{"id":10263,"library":"starlette-admin","title":"Starlette Admin","description":"Starlette Admin is a fast, beautiful, and extensible administrative interface framework designed for Starlette and FastAPI applications. It provides a robust backend to manage your database models with support for various ORMs like SQLAlchemy, MongoDB (via Motor/Beanie), Odmantic, and Tortoise ORM. The current version is 0.16.0, and it maintains an active release cadence with frequent updates and bug fixes.","status":"active","version":"0.16.0","language":"en","source_language":"en","source_url":"https://github.com/jowilf/starlette-admin","tags":["admin","starlette","fastapi","orm","web-framework","dashboard"],"install":[{"cmd":"pip install starlette-admin","lang":"bash","label":"Core Installation"},{"cmd":"pip install \"starlette-admin[sqla]\"","lang":"bash","label":"With SQLAlchemy support"},{"cmd":"pip install \"starlette-admin[beanie]\"","lang":"bash","label":"With Beanie (MongoDB) support"},{"cmd":"pip install \"starlette-admin[full]\"","lang":"bash","label":"With all ORM and extra features"}],"dependencies":[{"reason":"Required for SQLAlchemyModelView. Installed via `[sqla]` extra.","package":"SQLAlchemy","optional":true},{"reason":"Required for BeanieModelView (MongoDB ODM). Installed via `[beanie]` extra.","package":"beanie","optional":true},{"reason":"Required for OdmanticModelView (MongoDB ODM). Installed via `[odmantic]` extra.","package":"odmantic","optional":true},{"reason":"Required for TortoiseORMModelView. Installed via `[tortoise]` extra.","package":"tortoise-orm","optional":true}],"imports":[{"note":"The Admin class is located in the `app` submodule.","wrong":"from starlette_admin import Admin","symbol":"Admin","correct":"from starlette_admin.app import Admin"},{"note":"ORM-specific ModelViews are located in `contrib.*` submodules (e.g., `sqla`, `beanie`). The base `ModelView` in `views` is abstract.","wrong":"from starlette_admin.views import ModelView","symbol":"ModelView","correct":"from starlette_admin.contrib.sqla import ModelView"},{"symbol":"BaseModelView","correct":"from starlette_admin.views import BaseModelView"}],"quickstart":{"code":"import uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.orm import declarative_base, sessionmaker\n\nfrom starlette_admin.app import Admin\nfrom starlette_admin.contrib.sqla import ModelView\n\n# 1. Setup Database (SQLAlchemy Example)\nDATABASE_URL = \"sqlite:///./test.db\"\nengine = create_engine(DATABASE_URL, connect_args={\"check_same_thread\": False})\nSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)\nBase = declarative_base()\n\nclass User(Base):\n    __tablename__ = \"users\"\n    id = Column(Integer, primary_key=True, index=True)\n    name = Column(String)\n    email = Column(String, unique=True, index=True)\n\n# Create tables\nBase.metadata.create_all(bind=engine)\n\n# 2. Setup FastAPI App\napp = FastAPI()\n\n# 3. Setup Starlette Admin\nadmin = Admin(engine, title=\"My Admin Dashboard\")\n\n# Add ModelViews\nadmin.add_view(ModelView(User))\n\n# Mount Admin to FastAPI\nadmin.mount_to(app)\n\n# Optional: Add a root route\n@app.get(\"/\", include_in_schema=False)\nasync def read_root():\n    return {\"message\": \"Welcome to FastAPI with Starlette Admin!\"}\n\nif __name__ == \"__main__\":\n    # Populate some data if needed (run once)\n    with SessionLocal() as db:\n        if not db.query(User).first():\n            db.add(User(name=\"Alice\", email=\"alice@example.com\"))\n            db.add(User(name=\"Bob\", email=\"bob@example.com\"))\n            db.commit()\n    uvicorn.run(app, host=\"0.0.0.0\", port=8000)\n","lang":"python","description":"This quickstart demonstrates how to integrate Starlette Admin with a FastAPI application using SQLAlchemy. It sets up a basic `User` model, initializes the admin interface with a `ModelView` for `User`, and mounts it to the FastAPI app. Ensure you install `starlette-admin[sqla]` and `uvicorn` to run this example."},"warnings":[{"fix":"Install with `pip install \"starlette-admin[<orm_name>]\"` (e.g., `starlette-admin[sqla]`)","message":"When using ORM-specific ModelViews (e.g., `SQLAlchemyModelView`, `BeanieModelView`), ensure you install the correct extra dependencies (e.g., `starlette-admin[sqla]`, `starlette-admin[beanie]`) to avoid `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review Odmantic v1.0 migration guides and update your Odmantic models and database interactions accordingly. Then, upgrade `starlette-admin`.","message":"Version 0.15.0 upgraded Odmantic support to v1.0+. If you were using Odmantic with an older version of `starlette-admin` (pre-0.15.0) and Odmantic v0.x, you might face breaking changes due to Odmantic's API changes.","severity":"breaking","affected_versions":"<0.15.0 (when upgrading from older Odmantic)"},{"fix":"Implement custom authentication/authorization using Starlette/FastAPI's security features and integrate it with Starlette Admin via custom routes or middleware.","message":"Authentication and authorization are not included by default. You must implement your own security layer (e.g., using `starlette.middleware.authentication.AuthMiddleware` or FastAPI's dependency injection) to protect your admin panel.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `starlette-admin` version 0.15.0 or newer to resolve these warnings. No code changes are typically required on your end unless you've customized templates.","message":"Older versions (pre-0.15.0) might trigger deprecation warnings related to `TemplateResponse` and `Jinja2Templates` usage from Starlette. These have been addressed in 0.15.0.","severity":"deprecated","affected_versions":"<0.15.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install `starlette-admin` with the SQLAlchemy extra: `pip install \"starlette-admin[sqla]`\"","cause":"Attempting to use `SQLAlchemyModelView` without installing the `sqla` extra dependency.","error":"ModuleNotFoundError: No module named 'sqlalchemy'"},{"fix":"Pass your database engine (e.g., SQLAlchemy `engine`, Beanie `database`, etc.) to the `Admin` constructor: `admin = Admin(engine=my_engine)`","cause":"The `Admin` class constructor requires a database engine/client instance when using ORM-specific ModelViews, or you are trying to instantiate `Admin` without any arguments for CustomViews.","error":"TypeError: Admin.__init__() missing 1 required positional argument: 'engine'"},{"fix":"Ensure `Base.metadata.create_all(bind=engine)` is executed to create your database schema when your application starts.","cause":"This error often occurs when setting up SQLAlchemy and forgetting to call `Base.metadata.create_all(bind=engine)` to create the database tables before Starlette Admin tries to access them.","error":"TypeError: 'User' object is not callable"},{"fix":"Use `session.add(obj)` for single objects and `session.add_all([obj1, obj2])` for iterables of objects.","cause":"This specific error is less about starlette-admin and more about direct SQLAlchemy usage, but a common pitfall is mixing `session.add()` for single objects with `session.add_all()` for lists of objects. Ensure your bulk insertions match the correct SQLAlchemy session method.","error":"AttributeError: 'Session' object has no attribute 'add_all'"}]}