Configuration
You should configure predefined app
from fastapi-admin
on startup event of fastapi
, because which should be in
asyncio loop context.
import aioredis
from fastapi import FastAPI
from fastapi_admin.app import app as admin_app
from fastapi_admin.providers.login import UsernamePasswordProvider
from examples.models import Admin
app = FastAPI()
@app.on_event("startup")
async def startup():
redis = await aioredis.create_redis_pool(address='redis://localhost')
await admin_app.configure(
logo_url="https://preview.tabler.io/static/logo-white.svg",
template_folders=["templates"],
providers=[
UsernamePasswordProvider(
login_logo_url="https://preview.tabler.io/static/logo.svg", admin_model=Admin
)
],
redis=redis,
)
Parameters
logo_url
: Will show the logo image in admin dashboard.admin_path
: Default is/admin
, but you can change to other path.maintenance
: If set totrue
, all pages will be redirected to the/maintenance
page. (đ Pro only)redis
: Instance ofaioredis
.default_locale
: Current supportzh_CN
anden_US
, default isen_US
.template_folders
: Template folders registered to jinja2 and also can be used to override builtin templates.providers
: List of providers to register, all are subclasses offastapi_admin.providers.Provider
.language_switch
: Whether show a language switch in page, default isTrue
.default_layout
: Set default layout, current there are both layoutslayout.html
andlayout-navbar.html
, default islayout.html
. (đ Pro only)
Last update:
July 7, 2023 09:36:36