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.

Overview

简体中文 | English

项目介绍

FastAPI-Amis-Admin

fastapi-amis-admin是一个拥有高性能,高效率,易拓展的fastapi管理后台框架.
启发自Django-Admin,并且拥有不逊色于Django-Admin的强大功能.

Pytest Package version Downloads Chat on Gitter 229036692

源码 · 在线演示 · 文档 · 文档打不开?


fastapi-amis-admin是一个基于fastapi+amis开发的高性能并且高效率 web-admin 框架,使用 Python 3.7+ 并基于标准的 Python 类型提示. fastapi-amis-admin开发的初衷是为了完善fastapi应用生态, 为fastapi web应用程序快速生成一个可视化管理后台.

关键特性

  • 性能极高:基于FastAPI, 可享受FastAPI的全部优势.

  • 效率更快:完善的编码类型提示, 代码可重用性更高.

  • 支持异步和同步混合编写: ORM基于SQLModel+Sqlalchemy, 可自由定制数据库类型, 支持同步及异步模式, 可拓展性强.

  • 前后端分离: 前端由Amis渲染, 后端接口由fastapi-amis-admin自动生成, 接口可重复利用.

  • 可拓展性强: 后台页面支持Amis页面及普通html页面,开发者可以很方便的自由定制界面.

  • 自动生成API文档: 由FastAPI自动生成接口文档,方便开发者调试,以及接口分享.

核心依赖

项目组成

fastapi-amis-admin由三部分核心模块组成,其中amis, fastapi-sqlmodel-crud 可作为独立模块单独使用,amis_admin基于前者共同构建.

  • amis: 基于baidu amispydantic数据模型构建库,用于快速生成/解析amis json 数据.
  • fastapi-sqlmodel-crud: 基于FastAPI+SQLModel, 用于快速构建Create,Read,Update,Delete通用API接口.
  • amis_admin: 启发自Django-Admin, 结合amis+fastapi-sqlmodel-crud, 用于快速构建Web Admin管理后台.

安装

pip install fastapi_amis_admin

简单示例

from fastapi import FastAPI
from fastapi_amis_admin.amis_admin.settings import Settings
from fastapi_amis_admin.amis_admin.site import AdminSite

# 创建FastAPI应用
app = FastAPI()

# 创建AdminSite实例
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///admisadmin.db'))

# 挂载后台管理系统
site.mount_app(app)

if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, debug=True)

模型管理示例

from fastapi import FastAPI
from sqlmodel import SQLModel
from fastapi_amis_admin.amis_admin.settings import Settings
from fastapi_amis_admin.amis_admin.site import AdminSite
from fastapi_amis_admin.amis_admin import admin
from fastapi_amis_admin.models.fields import Field

# 创建FastAPI应用
app = FastAPI()

# 创建AdminSite实例
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///admisadmin.db'))


# 先创建一个SQLModel模型,详细请参考: 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')


# 注册ModelAdmin
@site.register_admin
class CategoryAdmin(admin.ModelAdmin):
    page_schema = '分类管理'
    # 配置管理模型
    model = Category


# 挂载后台管理系统
site.mount_app(app)


# 创建初始化数据库表
@app.on_event("startup")
async def startup():
    await site.create_db_and_tables()


if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, debug=True)

表单管理示例

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.amis_admin import admin
from fastapi_amis_admin.amis_admin.settings import Settings
from fastapi_amis_admin.amis_admin.site import AdminSite
from fastapi_amis_admin.crud.schema import BaseApiOut
from fastapi_amis_admin.models.fields import Field

# 创建FastAPI应用
app = FastAPI()

# 创建AdminSite实例
site = AdminSite(settings=Settings(database_url_async='sqlite+aiosqlite:///admisadmin.db'))


# 注册FormAdmin
@site.register_admin
class UserLoginFormAdmin(admin.FormAdmin):
    page_schema = 'UserLoginForm'
    # 配置表单信息, 可省略
    form = Form(title='这是一个测试登录表单', submitText='登录')

    # 创建表单数据模型
    class schema(BaseModel):
        username: str = Field(..., title='用户名', min_length=3, max_length=30)
        password: str = Field(..., title='密码')

    # 处理表单提交数据
    async def handle(self, request: Request, data: BaseModel, **kwargs) -> BaseApiOut[Any]:
        if data.username == 'amisadmin' and data.password == 'amisadmin':
            return BaseApiOut(msg='登录成功!', data={'token': 'xxxxxx'})
        return BaseApiOut(status=-1, msg='用户名或密码错误!')


# 挂载后台管理系统
site.mount_app(app)

if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, debug=True)

界面预览

  • Open http://127.0.0.1:8000/admin/ in your browser:

ModelAdmin

  • Open http://127.0.0.1:8000/admin/docs in your browser:

Docs

相关项目

许可协议

  • fastapi-amis-admin基于Apache2.0开源免费使用,可以免费用于商业用途,但请在展示界面中明确显示关于FastAPI-Amis-Admin的版权信息.

鸣谢

感谢以下开发者对 FastAPI-Amis-Admin 作出的贡献:

Comments
  • Dialog buttons and title keep showing Chinese caption

    Dialog buttons and title keep showing Chinese caption

    fastapi-amis-admin>=0.2.3 fastapi_user_auth fastapi-scheduler

    All the UI (tables etc. is shown in en_US) but when i click on delete of a record or on pause in the scheduler the popup dialog show title and button captions in chinese.

    What am i doing wrong?

    bug 
    opened by swelcker 14
  • iframe无法指定外部src

    iframe无法指定外部src

    当iframe的src指定为不以site_url开头的外部地址时候,这个iframe page就无法加载。

    查看源码后感觉这个判断有问题 https://github.com/amisadmin/fastapi_amis_admin/blob/7e5d603a40755f772275d857e9b26276bd332029/fastapi_amis_admin/admin/admin.py#L647-L650

    应该改成这样:

    if self.site.settings.site_url and iframe.src.startswith(self.site.settings.site_url):
        self.page_schema.url = re.sub(r"^https?://", "", iframe.src)
    else:
        self.page_schema.url = iframe.src
    
    question 
    opened by Chaoyingz 9
  • 当模型的主键不是用的id,比如自定义成user_id ,设置pk_name后, 可以显示数据,但是编辑更新数据,会报405错误,是接口没有传递item_id参数

    当模型的主键不是用的id,比如自定义成user_id ,设置pk_name后, 可以显示数据,但是编辑更新数据,会报405错误,是接口没有传递item_id参数

    class Users(SQLModel,table = True): user_id: str =Field(default=None,primary_key=True) name: str = Field(title="昵称") face_url:str = Field(title='头像') gender: int = Field(title='性别') phone_number:Optional[str] = Field(title='手机号码',default=None) birth:datetime = Field(title='生日') email:str = Field(title='用户名') ex:Optional[str]= Field(title='扩展字段',default=None) create_time:datetime = Field(title='创建时间') app_manger_level:int = Field(title='用户等级')

    @site.register_admin class UserInfoAdmin(admin.ModelAdmin): group_schema = '基本管理' page_schema = '用户管理' model = Users pk_name = 'user_id'

    bug 
    opened by bebee 4
  • Sort Order of fields in Create and Update Dialog (_create_schema... are different)

    Sort Order of fields in Create and Update Dialog (_create_schema... are different)

    The Create Dialog uses exactly the sort order provided by the 'create_fields` list, the Update Dialog has a different sort order each time you start the ASGI instance.

    Reason: in _sqlmodel, the def _create_schema_update(self):and the def _create_schema_create(self): are very different. The createversion gives me the freedom to define which field i want to show for record creation, the update version checks against the 'readonly_fields' list, which seems to be a logical idea at first BUT takes the freedom away from me while i provide the ùpdate_fields`list.

    Solution/Proposal: Make the update function the same as create:

    def _create_schema_update(self):
        if self.schema_update:
            return self.schema_update
        if not self.update_fields:
            return super(SQLModelCrud, self)._create_schema_update()
        modelfields = list(
            filter(
                None,
                [self.parser.get_modelfield(field, deepcopy=True) for field in self.update_fields],
            )
        )
        return schema_create_by_modelfield(f"{self.schema_name_prefix}Update", modelfields, set_none=True)
    
    opened by swelcker 3
  • M2M 关系中,添加的其他字段,如何表现在前端?

    M2M 关系中,添加的其他字段,如何表现在前端?

    class ClassStudentLink(SQLModel, table=True):
        __tablename__ = 'class_student_link'
        class_id: Optional[int] = Field(
            default=None, foreign_key="class.id", primary_key=True, nullable=False
        )
        student_id: Optional[int] = Field(
            default=None, foreign_key="student.id", primary_key=True, nullable=False
        )
        comment: str = Field(..., title='备注', sa_column=Column(String(256), index=True))
    

    这样的数据表如何在前端进行展示呢?

    opened by dongfengweixiao 3
  • UX optimization/proposal for any overlay Dialog

    UX optimization/proposal for any overlay Dialog

    This is just an idea/proposal to optimize the user experience while using the UI. Any overlay dialog title only shows the action type, like Create or Update etc. I believe it would be helpfull if we add the page_schema.label in admin.admin.py to it.

                dialog=Dialog(
                    title=_("Create") + " " + _(self.page_schema.label),  # Something like this
                    size=SizeEnum.lg,
                    body=await self.get_create_form(request, bulk=bulk),
    
    opened by swelcker 2
  • 请教:fastapi-sqlmodel-crud 怎么使用?

    请教:fastapi-sqlmodel-crud 怎么使用?

    class Article(SQLModel, table=True): id: int = Field(default=None, primary_key=True, nullable=False) title: str = Field(title='ArticleTitle', max_length=200) description: Optional[str] = Field(default='', title='ArticleDescription', max_length=400) status: bool = Field(None, title='status') content: str = Field(title='ArticleContent')

    article_crud = SQLModelCrud(model=Article, engine=engine).register_crud()

    我想用的model的主键字段不是id,需要制定pk_name,请问SQLModelCrud的构造方法应该怎么写?

    opened by zinohome 2
  • 404

    404

    /demo (master)$ git pull $ python demo-model.py INFO: Started server process [23792] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: 127.0.0.1:13268 - "GET / HTTP/1.1" 404 Not Found INFO: 127.0.0.1:13268 - "GET /pwabuilder-sw.js HTTP/1.1" 40 04 Not Found

    opened by wanghaisheng 2
  • 'AsyncAdapt_asyncpg_cursor' object has no attribute 'lastrowid'

    'AsyncAdapt_asyncpg_cursor' object has no attribute 'lastrowid'

    使用 postgresql+asyncpg 时,当插入数据时,能够正常写入数据库,但是客户端会提示内部错误,终端提示没有 lastrowid 的问题。 YB0R2~7ZXG){`) H T6G8Y8 AttributeError: 'AsyncAdapt_asyncpg_cursor' object has no attribute 'lastrowid'

    如需更多有效信息,请告知

    opened by dongfengweixiao 2
  • Sourcery refactored master branch

    Sourcery refactored master branch

    Branch master refactored by Sourcery.

    If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

    See our documentation here.

    Run Sourcery locally

    Reduce the feedback loop during development by using the Sourcery editor plugin:

    Review changes via command line

    To manually merge these changes, make sure you're on the master branch, then run:

    git fetch origin sourcery/master
    git merge --ff-only FETCH_HEAD
    git reset HEAD^
    

    Help us improve this pull request!

    opened by sourcery-ai[bot] 2
  • sqlalchemy.exc.ArgumentError: Mapper mapped class UserRoleLink->auth_user_roles could not assemble any primary key columns for mapped table 'auth_user_roles'

    sqlalchemy.exc.ArgumentError: Mapper mapped class UserRoleLink->auth_user_roles could not assemble any primary key columns for mapped table 'auth_user_roles'

    您好,我在使用的过程中有一点点问题,希望能得到您的思路指导。

    报错信息如下:

    INFO:     Started reloader process [1] using StatReload
    Process SpawnProcess-1:
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
        self.run()
      File "/opt/conda/lib/python3.9/multiprocessing/process.py", line 108, in run
        self._target(*self._args, **self._kwargs)
      File "/opt/conda/lib/python3.9/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
        target(sockets=sockets)
      File "/opt/conda/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
        return asyncio.run(self.serve(sockets=sockets))
      File "/opt/conda/lib/python3.9/asyncio/runners.py", line 44, in run
        return loop.run_until_complete(main)
      File "/opt/conda/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
        return future.result()
      File "/opt/conda/lib/python3.9/site-packages/uvicorn/server.py", line 67, in serve
        config.load()
      File "/opt/conda/lib/python3.9/site-packages/uvicorn/config.py", line 477, in load
        self.loaded_app = import_from_string(self.app)
      File "/opt/conda/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string
        module = importlib.import_module(module_str)
      File "/opt/conda/lib/python3.9/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
      File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 850, in exec_module
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "/home/jovyan/./ui_server/main.py", line 7, in <module>
        from fastapi_user_auth.auth import AuthBackend
      File "/opt/conda/lib/python3.9/site-packages/fastapi_user_auth/auth/__init__.py", line 1, in <module>
        from .auth import Auth as Auth
      File "/opt/conda/lib/python3.9/site-packages/fastapi_user_auth/auth/auth.py", line 37, in <module>
        from .backends.base import BaseTokenStore
      File "/opt/conda/lib/python3.9/site-packages/fastapi_user_auth/auth/backends/base.py", line 3, in <module>
        from fastapi_user_auth.auth.schemas import BaseTokenData
      File "/opt/conda/lib/python3.9/site-packages/fastapi_user_auth/auth/schemas.py", line 5, in <module>
        from .models import BaseUser, EmailMixin, PasswordMixin, UsernameMixin
      File "/opt/conda/lib/python3.9/site-packages/fastapi_user_auth/auth/models.py", line 56, in <module>
        class UserRoleLink(SQLModel, table=True):
      File "/opt/conda/lib/python3.9/site-packages/sqlmodelx/main.py", line 182, in __init__
        DeclarativeMeta.__init__(cls, classname, bases, dict_used, **kw)
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/orm/decl_api.py", line 72, in __init__
        _as_declarative(reg, cls, dict_)
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 126, in _as_declarative
        return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 177, in setup_mapping
        return cfg_cls(registry, cls_, dict_, table, mapper_kw)
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 326, in __init__
        self._early_mapping(mapper_kw)
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 209, in _early_mapping
        self.map(mapper_kw)
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/orm/decl_base.py", line 1004, in map
        mapper_cls(self.cls, self.local_table, **self.mapper_args),
      File "<string>", line 2, in __init__
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/util/deprecations.py", line 298, in warned
        return fn(*args, **kwargs)
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/orm/mapper.py", line 685, in __init__
        self._configure_pks()
      File "/opt/conda/lib/python3.9/site-packages/sqlalchemy/orm/mapper.py", line 1370, in _configure_pks
        raise sa_exc.ArgumentError(
    sqlalchemy.exc.ArgumentError: Mapper mapped class UserRoleLink->auth_user_roles could not assemble any primary key columns for mapped table 'auth_user_roles'
    

    我的环境: FROM jupyterhub/k8s-singleuser-sample:1.2.0

    我的pip包版本: ` aiosqlite 0.17.0

    sqlalchemy_database 0.1.0

    sqlalchemy2-stubs 0.0.2a29

    sqlmodel 0.0.8

    sqlmodelx 0.0.4

    sqlparse 0.4.3

    `

    opened by Mrzhangjwei 1
  • Fix route_create IntegrityError

    Fix route_create IntegrityError

    INFO:     127.0.0.1:51978 - "POST /DomainNameAdmin/item HTTP/1.1" 500 Internal Server Error
    ERROR:    Exception in ASGI application
    Traceback (most recent call last):
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
        self.scope, self.receive, self.send
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
        return await self.app(scope, receive, send)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/fastapi/applications.py", line 270, in __call__
        await super().__call__(scope, receive, send)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/starlette/applications.py", line 124, in __call__
        await self.middleware_stack(scope, receive, send)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 184, in __call__
        raise exc
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/starlette/middleware/errors.py", line 162, in __call__
        await self.app(scope, receive, _send)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/starlette/middleware/base.py", line 106, in __call__
        response = await self.dispatch_func(request, call_next)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/sqlalchemy_database/_abc_async_database.py", line 102, in asgi_dispatch
        return await call_next(request)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/sqlalchemy_database/database.py", line 353, in __aexit__
        await session.commit()
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/sqlalchemy/ext/asyncio/session.py", line 583, in commit
        return await greenlet_spawn(self.sync_session.commit)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 115, in greenlet_spawn
        result = context.switch(*args, **kwargs)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1451, in commit
        self._transaction.commit(_to_root=self.future)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 827, in commit
        self._assert_active(prepared_ok=True)
      File "/Users/xtao/Source/tanying/tanying-yuming/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 608, in _assert_active
        code="7s2a",
    sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.IntegrityError) NOT NULL constraint failed: domain_name.expiration_date
    [SQL: INSERT INTO domain_name (domain_name, registrar, creation_date, expiration_date, emails, name, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]
    [parameters: ('baidu.com', 'MarkMonitor, Inc.', '1999-10-11 11:05:17.000000', None, '', '', '2023-01-03 16:52:57.901851', '2023-01-03 16:52:57.901864')]
    (Background on this error at: https://sqlalche.me/e/14/gkpj) (Background on this error at: https://sqlalche.me/e/14/7s2a)
    
    opened by xtao 0
  • Post array data to ModelAdmin.create, get wrong response

    Post array data to ModelAdmin.create, get wrong response

    using ModelAdmin Example, as default enable_bulk_create is False

    class CategoryAdmin(admin.ModelAdmin):
        page_schema = "Category"
        model = Category
        #enable_bulk_create = True
    

    post to /admin/CategoryAdmin/item

    use data [{"name":"1","description":"1"},{"name":"2","description":"2"}], get correct response value_error.jsondecode.

    but use data [{"name":"1","description":"1"}], get wrong response msg : success "data" : {"name" : "description", "description" : ""}`

    change enable_bulk_create = True

    class CategoryAdmin(admin.ModelAdmin):
        page_schema = "Category"
        model = Category
        enable_bulk_create = True
    

    post to /admin/CategoryAdmin/item

    use data [{"name":"1","description":"1"}] or [{"name":"1","description":"1"},{"name":"2","description":"2"}], get same wrong response msg : success "data" : {"name" : "description", "description" : ""}`

    opened by albertix 0
  • QuickSaveItemApi错误,请修正代码

    QuickSaveItemApi错误,请修正代码

    admin/admin.py 文件 中 : primaryField=self.pk_name, quickSaveItemApi=f"put:{self.router_path}/item/" + "${id}", 改为: primaryField=self.pk_name, quickSaveItemApi=f"put:{self.router_path}/item/${self.pk_name}" 否则pk_name不为id时,会报405错误

    opened by zinohome 3
  • 批量新增插入错误

    批量新增插入错误

    使用模板示例 https://gitee.com/Atomi/fastapi_amis_admin?_from=gitee_search#%E6%A8%A1%E5%9E%8B%E7%AE%A1%E7%90%86%E7%A4%BA%E4%BE%8B

    在管理页面中 http://127.0.0.1:8000/admin/#/admin/categoryadmin 点击 批量新增,输入多行后,插入结果为

    | CategoryName | Description | |--------------|-------------| | description | - |

    opened by albertix 0
  • 如何实现一个动态内容的下拉选择?

    如何实现一个动态内容的下拉选择?

    我希望能在每一次加载页面的时候根据情况生成下拉选择框的成员, 我尝试在get_form_item里截取当前item然后往里面添加一些新的选项, 但是新的选项过不了FastApi的校验, 我尝试修改枚举也无效, 似乎fastapi总是持有最开始的那个枚举. 当前代码如下:

    class NtpVersionEnum(Choices):
        t = "t"
        q = 'asd'
    
    @site.register_admin
    class 生成区域掩码(admin.FormAdmin):
        page_schema = '生成'
    
        form = Form(title='生成区域参数', submitText='提交')
    
        class schema(BaseModel):
            ntp_version: NtpVersionEnum = Field(NtpVersionEnum.t, title='NTP版本')
    
        async def handle(self, request: Request, data: BaseModel, **kwargs) -> BaseApiOut[Any]:
            return BaseApiOut(msg='登录成功!', data={'token': 'xxxxxx'})
    
        async def get_form_item(self, request: Request, modelfield: ModelField) -> Form:
            item = await super().get_form_item(request, modelfield)
    
            if item.label == 'NTP版本':
                global NtpVersionEnum
                new_enum = Choices('NtpVersionEnum', {'t': 't', 'q': 'q', 'apple': 'apple'})
                print(NtpVersionEnum._member_map_, NtpVersionEnum._member_names_)
                NtpVersionEnum._member_map_ = new_enum._member_map_
                NtpVersionEnum._member_names_ = new_enum._member_names_
                NtpVersionEnum._member_type_ = new_enum._member_type_
                objprint.objprint(NtpVersionEnum._member_map_, NtpVersionEnum._member_names_)
                objprint.objprint(NtpVersionEnum.__dict__)
    
                item.options.append(Select(value='apple', label='apple'))
    
            return item
    
    

    报错为:

    {"detail":[{"loc":["body","ntp_version"],"msg":"value is not a valid enumeration member; permitted: 't', 'q', 'apple'","type":"type_error.enum","ctx":{"enum_values":["t","q","apple"]}}]}
    

    说是不允许 apple, 实际上传入的就是 apple.

    我已经搜了一些关于如何动态定于应用于fastapi的enum的东西, 不过看起来很难, amis这里是否可能给出一个动态选项并且不使用枚举来约束呢? 如果不太复杂, 也可以给我一些指引, 我来做一个PR

    opened by myuanz 2
Releases(v0.4.2)
  • v0.4.2(Nov 16, 2022)

  • v0.4.1(Nov 8, 2022)

  • v0.4.0(Nov 1, 2022)

    What's Changed

    • Added missing Amis controls: by @swelcker in https://github.com/amisadmin/fastapi_amis_admin/pull/66

    Full Changelog: https://github.com/amisadmin/fastapi_amis_admin/compare/v0.3.1...v0.4.0

    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Oct 21, 2022)

  • v0.3.0(Oct 17, 2022)

    What's Changed

    • English Docs by @swelcker in https://github.com/amisadmin/fastapi_amis_admin/pull/61
    • translated code comments to english, as most developers use those comments as quick ref documentation by @swelcker in https://github.com/amisadmin/fastapi_amis_admin/pull/62
    • Changed Page(AmisNode), added css and mobileCS fields by @swelcker in https://github.com/amisadmin/fastapi_amis_admin/pull/63

    Full Changelog: https://github.com/amisadmin/fastapi_amis_admin/compare/v0.2.5...v0.3.0

    New Features

    Source code(tar.gz)
    Source code(zip)
  • v0.2.5(Oct 12, 2022)

    What's Changed

    • master by @swelcker in https://github.com/amisadmin/fastapi_amis_admin/pull/53
    • Fix None error on lower() by @alldevic in https://github.com/amisadmin/fastapi_amis_admin/pull/56
    • extending use of i18n for language change on the fly by @swelcker in https://github.com/amisadmin/fastapi_amis_admin/pull/58
    • BaseFormAction and FormAction for non Model related custom Dialog action by @swelcker in https://github.com/amisadmin/fastapi_amis_admin/pull/59

    New Contributors

    • @swelcker made their first contribution in https://github.com/amisadmin/fastapi_amis_admin/pull/53
    • @alldevic made their first contribution in https://github.com/amisadmin/fastapi_amis_admin/pull/56

    Full Changelog: https://github.com/amisadmin/fastapi_amis_admin/compare/v0.2.4...v0.2.5

    Source code(tar.gz)
    Source code(zip)
  • v0.2.4(Oct 1, 2022)

  • v0.2.3(Sep 27, 2022)

    What's Changed

    • add amis app logo by @Sug2077 in https://github.com/amisadmin/fastapi_amis_admin/pull/48

    New Contributors

    • @Sug2077 made their first contribution in https://github.com/amisadmin/fastapi_amis_admin/pull/48

    Full Changelog: https://github.com/amisadmin/fastapi_amis_admin/compare/v0.2.2...v0.2.3

    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Sep 22, 2022)

    What's Changed

    • Support custom theme by @Chaoyingz in https://github.com/amisadmin/fastapi_amis_admin/pull/43
    • Add pre-commit hooks by @Chaoyingz in https://github.com/amisadmin/fastapi_amis_admin/pull/45
    • Add table column filterable by @Chaoyingz in https://github.com/amisadmin/fastapi_amis_admin/pull/47

    New Contributors

    • @Chaoyingz made their first contribution in https://github.com/amisadmin/fastapi_amis_admin/pull/43

    Full Changelog: https://github.com/amisadmin/fastapi_amis_admin/compare/v0.2.1...v0.2.2

    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Aug 31, 2022)

  • v0.2.0(Jul 1, 2022)

  • v0.1.8(Jun 17, 2022)

  • v0.1.7(Jun 10, 2022)

  • v0.1.6(Jun 7, 2022)

  • v0.1.5(Jun 4, 2022)

  • v0.1.4(May 29, 2022)

  • v0.1.3(May 25, 2022)

  • v0.1.2(May 24, 2022)

  • v0.1.1(May 22, 2022)

  • v0.1.0(May 18, 2022)

  • v0.0.24(May 15, 2022)

  • v0.0.23(May 11, 2022)

  • v0.0.22(Apr 4, 2022)

  • v0.0.21(Mar 28, 2022)

  • v0.0.20(Mar 20, 2022)

  • v0.0.19(Mar 17, 2022)

  • v0.0.18(Mar 7, 2022)

  • v0.0.17(Mar 2, 2022)

  • v0.0.16(Feb 27, 2022)

  • v0.0.15(Feb 16, 2022)

Owner
AmisAdmin
AmisAdmin
High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).

fastapi-gino-arq-uvicorn High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (powered by Redis & PostgreSQL). Contents Get Star

Leo Sussan 351 Jan 4, 2023
fastapi-admin2 is an upgraded fastapi-admin, that supports ORM dialects, true Dependency Injection and extendability

FastAPI2 Admin Introduction fastapi-admin2 is an upgraded fastapi-admin, that supports ORM dialects, true Dependency Injection and extendability. Now

Glib 14 Dec 5, 2022
Light, Flexible and Extensible ASGI API framework

Starlite Starlite is a light and flexible ASGI API framework. Using Starlette and pydantic as foundations. Check out the Starlite documentation ?? Cor

null 1.5k Jan 4, 2023
Flask-vs-FastAPI - Understanding Flask vs FastAPI Web Framework. A comparison of two different RestAPI frameworks.

Flask-vs-FastAPI Understanding Flask vs FastAPI Web Framework. A comparison of two different RestAPI frameworks. IntroductionIn Flask is a popular mic

Mithlesh Navlakhe 1 Jan 1, 2022
Easily integrate socket.io with your FastAPI app 🚀

fastapi-socketio Easly integrate socket.io with your FastAPI app. Installation Install this plugin using pip: $ pip install fastapi-socketio Usage To

Srdjan Stankovic 210 Dec 23, 2022
Easily integrate socket.io with your FastAPI app 🚀

fastapi-socketio Easly integrate socket.io with your FastAPI app. Installation Install this plugin using pip: $ pip install fastapi-socketio Usage To

Srdjan Stankovic 37 Feb 12, 2021
A FastAPI Middleware of joerick/pyinstrument to check your service performance.

fastapi_profiler A FastAPI Middleware of joerick/pyinstrument to check your service performance. ?? Info A FastAPI Middleware of pyinstrument to check

LeoSun 107 Jan 5, 2023
SQLAlchemy Admin for Starlette/FastAPI

SQLAlchemy Admin for Starlette/FastAPI SQLAdmin is a flexible Admin interface for SQLAlchemy models. Main features include: SQLAlchemy sync/async engi

Amin Alaee 683 Jan 3, 2023
:rocket: CLI tool for FastAPI. Generating new FastAPI projects & boilerplates made easy.

Project generator and manager for FastAPI. Source Code: View it on Github Features ?? Creates customizable project boilerplate. Creates customizable a

Yagiz Degirmenci 1k Jan 2, 2023
Simple FastAPI Example : Blog API using FastAPI : Beginner Friendly

fastapi_blog FastAPI : Simple Blog API with CRUD operation Steps to run the project: git clone https://github.com/mrAvi07/fastapi_blog.git cd fastapi-

Avinash Alanjkar 1 Oct 8, 2022
Пример использования GraphQL Ariadne с FastAPI и сравнение его с GraphQL Graphene FastAPI

FastAPI Ariadne Example Пример использования GraphQL Ariadne с FastAPI и сравнение его с GraphQL Graphene FastAPI - GitHub ###Запуск на локальном окру

ZeBrains Team 9 Nov 10, 2022
Sample-fastapi - A sample app using Fastapi that you can deploy on App Platform

Getting Started We provide a sample app using Fastapi that you can deploy on App

Erhan BÜTE 2 Jan 17, 2022
FastAPI Server Session is a dependency-based extension for FastAPI that adds support for server-sided session management

FastAPI Server-sided Session FastAPI Server Session is a dependency-based extension for FastAPI that adds support for server-sided session management.

DevGuyAhnaf 5 Dec 23, 2022
Code Specialist 27 Oct 16, 2022
Fastapi-ml-template - Fastapi ml template with python

FastAPI ML Template Run Web API Local $ sh run.sh # poetry run uvicorn app.mai

Yuki Okuda 29 Nov 20, 2022
A FastAPI Framework for things like Database, Redis, Logging, JWT Authentication and Rate Limits

A FastAPI Framework for things like Database, Redis, Logging, JWT Authentication and Rate Limits Install You can install this Library with: pip instal

Tert0 33 Nov 28, 2022
API using python and Fastapi framework

Welcome ?? CFCApi is a API DEVELOPMENT PROJECT UNDER CODE FOR COMMUNITY ! Project Walkthrough ?? CFCApi run on Python using FASTapi Framework Docs The

Abhishek kushwaha 7 Jan 2, 2023
This is an API developed in python with the FastApi framework and putting into practice the recommendations of the book Clean Architecture in Python by Leonardo Giordani,

This is an API developed in python with the FastApi framework and putting into practice the recommendations of the book Clean Architecture in Python by Leonardo Giordani,

null 0 Sep 24, 2022
FastAPI framework plugins

Plugins for FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi-plugins FastAPI framework plugins Cache Mem

RES 239 Dec 28, 2022