[简体中文](https://github.com/amisadmin/fastapi_amis_admin/blob/master/README.zh.md)
| [English](https://github.com/amisadmin/fastapi_amis_admin)
# Introduction
<h2 align="center">
FastAPI-Amis-Admin
</h2>
<p align="center">
<em>fastapi-amis-admin is a high-performance, efficient and easily extensible FastAPI admin framework.</em><br/>
<em>Inspired by Django-admin, and has as many powerful functions as Django-admin.</em>
</p>
<p align="center">
<a href="https://github.com/amisadmin/fastapi_amis_admin/actions/workflows/pytest.yml" target="_blank">
<img src="https://github.com/amisadmin/fastapi_amis_admin/actions/workflows/pytest.yml/badge.svg" alt="Pytest">
</a>
<a href="https://pypi.org/project/fastapi_amis_admin" target="_blank">
<img src="https://badgen.net/pypi/v/fastapi-amis-admin?color=blue" alt="Package version">
</a>
<a href="https://pepy.tech/project/fastapi-amis-admin" target="_blank">
<img src="https://pepy.tech/badge/fastapi-amis-admin" alt="Downloads">
</a>
<a href="https://gitter.im/amisadmin/fastapi-amis-admin">
<img src="https://badges.gitter.im/amisadmin/fastapi-amis-admin.svg" alt="Chat on Gitter"/>
</a>
</p>
<p align="center">
<a href="https://github.com/amisadmin/fastapi_amis_admin" target="_blank">source code</a>
·
<a href="http://demo.amis.work/admin" target="_blank">online demo</a>
·
<a href="http://docs.gh.amis.work" target="_blank">documentation</a>
·
<a href="http://docs.amis.work" target="_blank">can't open the document?</a>
</p>
------
`fastapi-amis-admin` is a high-performance and efficient framework based on `fastapi` & `amis` with `Python 3.7+`, and
based on standard Python type hints. The original intention of the development is to improve the application ecology and
to quickly generate a visual dashboard for the web application . According to the `Apache2.0` protocol, it is free and
open source . But in order to better operate and maintain this project in the long run, I very much hope to get
everyone's sponsorship and support.
## Features
- **High performance**: Based on [FastAPI](https://fastapi.tiangolo.com/). Enjoy all the benefits.
- **High efficiency**: Perfect code type hints. Higher code reusability.
- **Support asynchronous and synchronous hybrid writing**: `ORM` is based on`SQLModel` & `Sqlalchemy`. Freely customize
database type. Support synchronous and asynchronous mode. Strong scalability.
- **Front-end separation**: The front-end is rendered by `Amis`, the back-end interface is automatically generated
by `fastapi-amis-admin`. The interface is reusable.
- **Strong scalability**: The background page supports `Amis` pages and ordinary `html` pages. Easily customize the
interface freely.
- **Automatic api documentation**: Automatically generate Interface documentation by `FastAPI`. Easily debug and share
interfaces.
## Dependencies
- [FastAPI](https://fastapi.tiangolo.com/): Finish the web part.
- [SQLModel](https://sqlmodel.tiangolo.com/): Finish `ORM` model mapping. Perfectly
combine [SQLAlchemy](https://www.sqlalchemy.org/) with [Pydantic](https://pydantic-docs.helpmanual.io/), and have all
their features .
- [Amis](https://baidu.gitee.io/amis): Finish admin page presentation.
## Composition
`fastapi-amis-admin` consists of three core modules, of which, `amis`, `fastapi-sqlmodel-crud` can be used as separate
modules, `amis_admin` is developed by the former.
- `amis`: Based on the `pydantic` data model building library of `baidu amis`. To generate/parse data rapidly.
- `fastapi-sqlmodel-crud`: Based on `FastAPI` &`SQLModel`. To quickly build Create, Read, Update, Delete common API
interface .
- `admin`: Inspired by `Django-Admin`. Combine `amis` with `fastapi-sqlmodel-crud`. To quickly build Web Admin
dashboard .
## Installation
```bash
pip install fastapi_amis_admin
```
## Simple Example
```python
from fastapi import FastAPI
from fastapi_amis_admin.admin.settings import Settings
from fastapi_amis_admin.admin.site import AdminSite
# create FastAPI application
app = FastAPI()
# create AdminSite instance
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))
# mount AdminSite instance
site.mount_app(app)
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, debug=True)
```
## ModelAdmin Example
```python
from fastapi import FastAPI
from sqlmodel import SQLModel
from fastapi_amis_admin.admin.settings import Settings
from fastapi_amis_admin.admin.site import AdminSite
from fastapi_amis_admin.admin import admin
from fastapi_amis_admin.models.fields import Field
# create FastAPI application
app = FastAPI()
# create AdminSite instance
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))
# Create an SQLModel, see document for details: https://sqlmodel.tiangolo.com/
class Category(SQLModel, table=True):
id: int = Field(default=None, primary_key=True, nullable=False)
name: str = Field(title='CategoryName')
description: str = Field(default='', title='Description')
# register ModelAdmin
@site.register_admin
class CategoryAdmin(admin.ModelAdmin):
page_schema = 'Category'
# set model
model = Category
# mount AdminSite instance
site.mount_app(app)
# create initial database table
@app.on_event("startup")
async def startup():
await site.db.async_run_sync(SQLModel.metadata.create_all, is_session=False)
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, debug=True)
```
## FormAdmin Example
```python
from typing import Any
from fastapi import FastAPI
from pydantic import BaseModel
from starlette.requests import Request
from fastapi_amis_admin.amis.components import Form
from fastapi_amis_admin.admin import admin
from fastapi_amis_admin.admin.settings import Settings
from fastapi_amis_admin.admin.site import AdminSite
from fastapi_amis_admin.crud.schema import BaseApiOut
from fastapi_amis_admin.models.fields import Field
# create FastAPI application
app = FastAPI()
# create AdminSite instance
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))
# register FormAdmin
@site.register_admin
class UserLoginFormAdmin(admin.FormAdmin):
page_schema = 'UserLoginForm'
# set form information, optional
form = Form(title='This is a test login form', submitText='login')
# create form schema
class schema(BaseModel):
username: str = Field(..., title='username', min_length=3, max_length=30)
password: str = Field(..., title='password')
# handle form submission data
async def handle(self, request: Request, data: BaseModel, **kwargs) -> BaseApiOut[Any]:
if data.username == 'amisadmin' and data.password == 'amisadmin':
return BaseApiOut(msg='Login successfully!', data={'token': 'xxxxxx'})
return BaseApiOut(status=-1, msg='Incorrect username or password!')
# mount AdminSite instance
site.mount_app(app)
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, debug=True)
```
## Working with Command
```bash
# Install command line extension
pip install fastapi_amis_admin[cli]
# View help
faa --help
# Initialize a `FastAPI-Amis-Admin` project
faa new project_name --init
# Initialize a `FastAPI-Amis-Admin` application
faa new app_name
# Fast running project
faa run
```
## Preview
- Open `http://127.0.0.1:8000/admin/` in your browser:
![ModelAdmin](https://s2.loli.net/2022/03/20/ItgFYGUONm1jCz5.png)
- Open `http://127.0.0.1:8000/admin/docs` in your browser:
![Docs](https://s2.loli.net/2022/03/20/1GcCiPdmXayxrbH.png)
## Project
- [`Amis-Admin-Theme-Editor`](https://github.com/swelcker/amis-admin-theme-editor):Theme-Editor for the fastapi-amis-admin.
Allows to add custom css styles and to apply theme --vars change on the fly.
- [`FastAPI-User-Auth`](https://github.com/amisadmin/fastapi_user_auth): A simple and powerful `FastAPI` user `RBAC`
authentication and authorization library.
- [`FastAPI-Scheduler`](https://github.com/amisadmin/fastapi_scheduler): A simple scheduled task management `FastAPI` extension
based on `APScheduler`.
- [`FastAPI-Amis-Admin-Demo`](https://github.com/amisadmin/fastapi_amis_admin_demo): An example `FastAPI-Amis-Admin` application.
- [`FastAPI-User-Auth-Demo`](https://github.com/amisadmin/fastapi_user_auth_demo): An example `FastAPI-User-Auth` application.
## License
- According to the `Apache2.0` protocol, `fastapi-amis-admin` is free and open source. It can be used for commercial for
free, but please clearly display copyright information about `FastAPI-Amis-Admin` on the display interface.
Raw data
{
"_id": null,
"home_page": null,
"name": "fastapi-amis-admin",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "Atomi <1456417373@qq.com>",
"keywords": "fastapi,fastapi-admin,fastapi-amis-admin,django-admin,sqlmodel,sqlalchemy",
"author": null,
"author_email": "Atomi <1456417373@qq.com>",
"download_url": "https://files.pythonhosted.org/packages/c4/74/c74bf2740c7f591bb34d9eba661a64aeadc725df6cc37230a4962c257f96/fastapi_amis_admin-0.5.8.tar.gz",
"platform": null,
"description": "[\u7b80\u4f53\u4e2d\u6587](https://github.com/amisadmin/fastapi_amis_admin/blob/master/README.zh.md)\n| [English](https://github.com/amisadmin/fastapi_amis_admin)\n\n# Introduction\n\n<h2 align=\"center\">\n FastAPI-Amis-Admin\n</h2>\n<p align=\"center\">\n <em>fastapi-amis-admin is a high-performance, efficient and easily extensible FastAPI admin framework.</em><br/>\n <em>Inspired by Django-admin, and has as many powerful functions as Django-admin.</em>\n</p>\n<p align=\"center\">\n <a href=\"https://github.com/amisadmin/fastapi_amis_admin/actions/workflows/pytest.yml\" target=\"_blank\">\n <img src=\"https://github.com/amisadmin/fastapi_amis_admin/actions/workflows/pytest.yml/badge.svg\" alt=\"Pytest\">\n </a>\n <a href=\"https://pypi.org/project/fastapi_amis_admin\" target=\"_blank\">\n <img src=\"https://badgen.net/pypi/v/fastapi-amis-admin?color=blue\" alt=\"Package version\">\n </a>\n <a href=\"https://pepy.tech/project/fastapi-amis-admin\" target=\"_blank\">\n <img src=\"https://pepy.tech/badge/fastapi-amis-admin\" alt=\"Downloads\">\n </a>\n <a href=\"https://gitter.im/amisadmin/fastapi-amis-admin\">\n <img src=\"https://badges.gitter.im/amisadmin/fastapi-amis-admin.svg\" alt=\"Chat on Gitter\"/>\n </a>\n</p>\n<p align=\"center\">\n <a href=\"https://github.com/amisadmin/fastapi_amis_admin\" target=\"_blank\">source code</a>\n \u00b7\n <a href=\"http://demo.amis.work/admin\" target=\"_blank\">online demo</a>\n \u00b7\n <a href=\"http://docs.gh.amis.work\" target=\"_blank\">documentation</a>\n \u00b7\n <a href=\"http://docs.amis.work\" target=\"_blank\">can't open the document?</a>\n</p>\n\n\n------\n\n`fastapi-amis-admin` is a high-performance and efficient framework based on `fastapi` & `amis` with `Python 3.7+`, and\nbased on standard Python type hints. The original intention of the development is to improve the application ecology and\nto quickly generate a visual dashboard for the web application . According to the `Apache2.0` protocol, it is free and\nopen source . But in order to better operate and maintain this project in the long run, I very much hope to get\neveryone's sponsorship and support.\n\n## Features\n\n- **High performance**: Based on [FastAPI](https://fastapi.tiangolo.com/). Enjoy all the benefits.\n- **High efficiency**: Perfect code type hints. Higher code reusability.\n- **Support asynchronous and synchronous hybrid writing**: `ORM` is based on`SQLModel` & `Sqlalchemy`. Freely customize\n database type. Support synchronous and asynchronous mode. Strong scalability.\n- **Front-end separation**: The front-end is rendered by `Amis`, the back-end interface is automatically generated\n by `fastapi-amis-admin`. The interface is reusable.\n- **Strong scalability**: The background page supports `Amis` pages and ordinary `html` pages. Easily customize the\n interface freely.\n- **Automatic api documentation**: Automatically generate Interface documentation by `FastAPI`. Easily debug and share\n interfaces.\n\n## Dependencies\n\n- [FastAPI](https://fastapi.tiangolo.com/): Finish the web part.\n- [SQLModel](https://sqlmodel.tiangolo.com/): Finish `ORM` model mapping. Perfectly\n combine [SQLAlchemy](https://www.sqlalchemy.org/) with [Pydantic](https://pydantic-docs.helpmanual.io/), and have all\n their features .\n- [Amis](https://baidu.gitee.io/amis): Finish admin page presentation.\n\n## Composition\n\n`fastapi-amis-admin` consists of three core modules, of which, `amis`, `fastapi-sqlmodel-crud` can be used as separate\nmodules, `amis_admin` is developed by the former.\n\n- `amis`: Based on the `pydantic` data model building library of `baidu amis`. To generate/parse data rapidly.\n- `fastapi-sqlmodel-crud`: Based on `FastAPI` &`SQLModel`. To quickly build Create, Read, Update, Delete common API\n interface .\n- `admin`: Inspired by `Django-Admin`. Combine `amis` with `fastapi-sqlmodel-crud`. To quickly build Web Admin\n dashboard .\n\n## Installation\n\n```bash\npip install fastapi_amis_admin\n```\n\n## Simple Example\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_amis_admin.admin.settings import Settings\nfrom fastapi_amis_admin.admin.site import AdminSite\n\n# create FastAPI application\napp = FastAPI()\n\n# create AdminSite instance\nsite = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))\n\n# mount AdminSite instance\nsite.mount_app(app)\n\nif __name__ == '__main__':\n import uvicorn\n\n uvicorn.run(app, debug=True)\n```\n\n## ModelAdmin Example\n\n```python\nfrom fastapi import FastAPI\nfrom sqlmodel import SQLModel\nfrom fastapi_amis_admin.admin.settings import Settings\nfrom fastapi_amis_admin.admin.site import AdminSite\nfrom fastapi_amis_admin.admin import admin\nfrom fastapi_amis_admin.models.fields import Field\n\n# create FastAPI application\napp = FastAPI()\n\n# create AdminSite instance\nsite = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))\n\n\n# Create an SQLModel, see document for details: https://sqlmodel.tiangolo.com/\nclass Category(SQLModel, table=True):\n id: int = Field(default=None, primary_key=True, nullable=False)\n name: str = Field(title='CategoryName')\n description: str = Field(default='', title='Description')\n\n\n# register ModelAdmin\n@site.register_admin\nclass CategoryAdmin(admin.ModelAdmin):\n page_schema = 'Category'\n # set model\n model = Category\n\n\n# mount AdminSite instance\nsite.mount_app(app)\n\n\n# create initial database table\n@app.on_event(\"startup\")\nasync def startup():\n await site.db.async_run_sync(SQLModel.metadata.create_all, is_session=False)\n\n\nif __name__ == '__main__':\n import uvicorn\n\n uvicorn.run(app, debug=True)\n```\n\n## FormAdmin Example\n\n```python\nfrom typing import Any\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\nfrom starlette.requests import Request\nfrom fastapi_amis_admin.amis.components import Form\nfrom fastapi_amis_admin.admin import admin\nfrom fastapi_amis_admin.admin.settings import Settings\nfrom fastapi_amis_admin.admin.site import AdminSite\nfrom fastapi_amis_admin.crud.schema import BaseApiOut\nfrom fastapi_amis_admin.models.fields import Field\n\n# create FastAPI application\napp = FastAPI()\n\n# create AdminSite instance\nsite = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///amisadmin.db'))\n\n\n# register FormAdmin\n@site.register_admin\nclass UserLoginFormAdmin(admin.FormAdmin):\n page_schema = 'UserLoginForm'\n # set form information, optional\n form = Form(title='This is a test login form', submitText='login')\n\n # create form schema\n class schema(BaseModel):\n username: str = Field(..., title='username', min_length=3, max_length=30)\n password: str = Field(..., title='password')\n\n # handle form submission data\n async def handle(self, request: Request, data: BaseModel, **kwargs) -> BaseApiOut[Any]:\n if data.username == 'amisadmin' and data.password == 'amisadmin':\n return BaseApiOut(msg='Login successfully!', data={'token': 'xxxxxx'})\n return BaseApiOut(status=-1, msg='Incorrect username or password!')\n\n\n# mount AdminSite instance\nsite.mount_app(app)\n\nif __name__ == '__main__':\n import uvicorn\n\n uvicorn.run(app, debug=True)\n```\n\n## Working with Command\n\n```bash\n# Install command line extension\npip install fastapi_amis_admin[cli]\n\n# View help\nfaa --help\n\n# Initialize a `FastAPI-Amis-Admin` project\nfaa new project_name --init\n\n# Initialize a `FastAPI-Amis-Admin` application\nfaa new app_name\n\n# Fast running project\nfaa run\n```\n\n## Preview\n\n- Open `http://127.0.0.1:8000/admin/` in your browser:\n\n![ModelAdmin](https://s2.loli.net/2022/03/20/ItgFYGUONm1jCz5.png)\n\n- Open `http://127.0.0.1:8000/admin/docs` in your browser:\n\n![Docs](https://s2.loli.net/2022/03/20/1GcCiPdmXayxrbH.png)\n\n## Project\n\n- [`Amis-Admin-Theme-Editor`](https://github.com/swelcker/amis-admin-theme-editor):Theme-Editor for the fastapi-amis-admin. \n Allows to add custom css styles and to apply theme --vars change on the fly.\n- [`FastAPI-User-Auth`](https://github.com/amisadmin/fastapi_user_auth): A simple and powerful `FastAPI` user `RBAC`\n authentication and authorization library.\n- [`FastAPI-Scheduler`](https://github.com/amisadmin/fastapi_scheduler): A simple scheduled task management `FastAPI` extension\n based on `APScheduler`.\n- [`FastAPI-Amis-Admin-Demo`](https://github.com/amisadmin/fastapi_amis_admin_demo): An example `FastAPI-Amis-Admin` application.\n- [`FastAPI-User-Auth-Demo`](https://github.com/amisadmin/fastapi_user_auth_demo): An example `FastAPI-User-Auth` application.\n\n## License\n\n- According to the `Apache2.0` protocol, `fastapi-amis-admin` is free and open source. It can be used for commercial for\n free, but please clearly display copyright information about `FastAPI-Amis-Admin` on the display interface.\n\n",
"bugtrack_url": null,
"license": null,
"summary": "FastAPI-Amis-Admin is a high-performance, efficient and easily extensible FastAPI admin framework. Inspired by Django-admin, and has as many powerful functions as Django-admin. ",
"version": "0.5.8",
"project_urls": {
"Documentation": "http://docs.amis.work/",
"Source": "https://github.com/amisadmin/fastapi_amis_admin"
},
"split_keywords": [
"fastapi",
"fastapi-admin",
"fastapi-amis-admin",
"django-admin",
"sqlmodel",
"sqlalchemy"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4282b35fc0d59537f6b8cbeb26a59a5ff1b58ad5c227b4d02308731cc6cbc052",
"md5": "04d9150bdfd456758fa43ff2d304676a",
"sha256": "310871a84d4e20e64c74d0d807263a54ca66fb8eed956913e192f40c253d73a1"
},
"downloads": -1,
"filename": "fastapi_amis_admin-0.5.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "04d9150bdfd456758fa43ff2d304676a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 97989,
"upload_time": "2023-07-06T04:25:32",
"upload_time_iso_8601": "2023-07-06T04:25:32.100235Z",
"url": "https://files.pythonhosted.org/packages/42/82/b35fc0d59537f6b8cbeb26a59a5ff1b58ad5c227b4d02308731cc6cbc052/fastapi_amis_admin-0.5.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "c474c74bf2740c7f591bb34d9eba661a64aeadc725df6cc37230a4962c257f96",
"md5": "6cb16bff1f33a01b4524dc6c021fc99c",
"sha256": "a5dc5825c929f040acdabafc79d9b2b7ff1a22518f3e6076d145fbd4f5aa44f2"
},
"downloads": -1,
"filename": "fastapi_amis_admin-0.5.8.tar.gz",
"has_sig": false,
"md5_digest": "6cb16bff1f33a01b4524dc6c021fc99c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 470528,
"upload_time": "2023-07-06T04:25:34",
"upload_time_iso_8601": "2023-07-06T04:25:34.460415Z",
"url": "https://files.pythonhosted.org/packages/c4/74/c74bf2740c7f591bb34d9eba661a64aeadc725df6cc37230a4962c257f96/fastapi_amis_admin-0.5.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-06 04:25:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "amisadmin",
"github_project": "fastapi_amis_admin",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "fastapi-amis-admin"
}