mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2026-03-13 10:32:25 +08:00
complete documentation
This commit is contained in:
2
.github/workflows/deploy.yml
vendored
2
.github/workflows/deploy.yml
vendored
@@ -1,5 +1,5 @@
|
||||
name: deploy
|
||||
on: push
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
20
.github/workflows/docs.yml
vendored
Normal file
20
.github/workflows/docs.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: docs
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'docs/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'docs/**'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: dschep/install-poetry-action@v1.3
|
||||
- name: Deploy docs
|
||||
run: make deploy-docs
|
||||
|
||||
2
.github/workflows/pypi.yml
vendored
2
.github/workflows/pypi.yml
vendored
@@ -18,4 +18,4 @@ jobs:
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.pypi_password }}
|
||||
password: ${{ secrets.pypi_password }}
|
||||
|
||||
6
Makefile
6
Makefile
@@ -35,5 +35,7 @@ build: deps
|
||||
@poetry build
|
||||
|
||||
docs: deps
|
||||
@pip install -r docs/requirements.txt
|
||||
@sphinx-build docs/ docs/_build
|
||||
@mkdocs build
|
||||
|
||||
deploy-docs: docs
|
||||
@mkdocs gh-deploy
|
||||
|
||||
@@ -93,6 +93,10 @@ async def startup():
|
||||
)
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
See documentation at [https://long2ice.github.io/fastapi-admin](https://long2ice.github.io/fastapi-admin).
|
||||
|
||||
## Deployment
|
||||
|
||||
Deploy fastapi app by gunicorn+uvicorn or reference
|
||||
|
||||
@@ -1,7 +1,102 @@
|
||||
## Import app
|
||||
|
||||
First of all suppose you have a fastapi+tortoise-orm project and running normally, then first you should is import admin app from `fastapi-admin` and mount in root fastapi app.
|
||||
|
||||
```python hl_lines="6"
|
||||
from fastapi_admin.factory import app as admin_app
|
||||
|
||||
def create_app():
|
||||
fast_app = FastAPI(debug=False)
|
||||
register_tortoise(fast_app, config=TORTOISE_ORM)
|
||||
fast_app.mount("/admin", admin_app)
|
||||
return fast_app
|
||||
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("main:app", port=8000, debug=False, reload=False, lifespan="on")
|
||||
|
||||
```
|
||||
|
||||
Now you can visit `http://127.0.0.1:8000/admin/docs` see all restful api comes from fastapi-admin.
|
||||
|
||||
## Init App
|
||||
|
||||
## Site configuration
|
||||
After mount admin app, you should init app now. Pay attention to that you should init admin app in fastapi `startup` event instead of run it directly.
|
||||
|
||||
## Menu configuration
|
||||
```python
|
||||
@app.on_event("startup")
|
||||
async def start_up():
|
||||
await admin_app.init( # nosec
|
||||
admin_secret="test",
|
||||
permission=True,
|
||||
admin_log=True,
|
||||
site=Site(
|
||||
name="FastAPI-Admin DEMO",
|
||||
login_footer="FASweTAPI ADMIN - FastAPI Admin Dashboard",
|
||||
login_description="FastAPI Admin Dashboard",
|
||||
locale="en-US",
|
||||
locale_switcher=True,
|
||||
theme_switcher=True,
|
||||
menus=[
|
||||
Menu(name="Home", url="/", icon="fa fa-home"),
|
||||
Menu(
|
||||
name="Content",
|
||||
children=[
|
||||
Menu(
|
||||
name="Category",
|
||||
url="/rest/Category",
|
||||
icon="fa fa-list",
|
||||
search_fields=("slug",),
|
||||
),
|
||||
Menu(
|
||||
name="Config",
|
||||
url="/rest/Config",
|
||||
icon="fa fa-gear",
|
||||
import_=True,
|
||||
search_fields=("key",),
|
||||
),
|
||||
Menu(
|
||||
name="Product",
|
||||
url="/rest/Product",
|
||||
icon="fa fa-table",
|
||||
search_fields=("name",),
|
||||
),
|
||||
],
|
||||
),
|
||||
Menu(
|
||||
name="External",
|
||||
children=[
|
||||
Menu(
|
||||
name="Github",
|
||||
url="https://github.com/long2ice/fastapi-admin",
|
||||
icon="fa fa-github",
|
||||
external=True,
|
||||
),
|
||||
],
|
||||
),
|
||||
Menu(
|
||||
name="Auth",
|
||||
children=[
|
||||
Menu(
|
||||
name="User",
|
||||
url="/rest/User",
|
||||
icon="fa fa-user",
|
||||
search_fields=("username",),
|
||||
),
|
||||
Menu(name="Role", url="/rest/Role", icon="fa fa-group",),
|
||||
Menu(name="Permission", url="/rest/Permission", icon="fa fa-user-plus",),
|
||||
Menu(
|
||||
name="AdminLog",
|
||||
url="/rest/AdminLog",
|
||||
icon="fa fa-align-left",
|
||||
search_fields=("action", "admin", "model"),
|
||||
),
|
||||
Menu(name="Logout", url="/logout", icon="fa fa-lock",),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
```
|
||||
|
||||
@@ -10,10 +10,9 @@ theme:
|
||||
repo: fontawesome/brands/github
|
||||
markdown_extensions:
|
||||
- pymdownx.highlight
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.superfences
|
||||
nav:
|
||||
- index.md
|
||||
- features.md
|
||||
- tutorial.md
|
||||
- site_define.md
|
||||
- menu_define.md
|
||||
- features.md
|
||||
|
||||
Reference in New Issue
Block a user