FastAPI Admin Dashboard based on FastAPI and Tortoise ORM.

Overview

FastAPI ADMIN

image image image image

中文文档

Introduction

FastAPI-Admin is a admin dashboard based on fastapi and tortoise-orm.

FastAPI-Admin provide crud feature out-of-the-box with just a few config.

Live Demo

Check a live Demo here https://fastapi-admin.long2ice.cn.

  • username: admin
  • password: 123456

Data in database will restore every day.

Screenshots

image

image

image

image

Requirements

  • FastAPI framework as your backend framework.
  • Tortoise-ORM as your orm framework, by the way, which is best asyncio orm so far and I'm one of the contributors 😋 .

Quick Start

Run Backend

Look full example at examples.

  1. git clone https://github.com/long2ice/fastapi-admin.git.
  2. docker-compose up -d --build.
  3. docker-compose exec -T mysql mysql -uroot -p123456 < examples/example.sql fastapi-admin.
  4. That's just all, api server is listen at http://127.0.0.1:8000 now.

Run Front

See restful-admin for reference.

Backend Integration

> pip3 install fastapi-admin
from fastapi_admin.factory import app as admin_app

fast_app = FastAPI()

register_tortoise(fast_app, config=TORTOISE_ORM, generate_schemas=True)

fast_app.mount('/admin', admin_app)

@fast_app.on_event('startup')
async def startup():
    await admin_app.init(
        admin_secret="test",
        permission=True,
        site=Site(
            name="FastAPI-Admin DEMO",
            login_footer="FASTAPI ADMIN - FastAPI Admin Dashboard",
            login_description="FastAPI Admin Dashboard",
            locale="en-US",
            locale_switcher=True,
            theme_switcher=True,
        ),
    )

Documentation

See documentation at https://long2ice.github.io/fastapi-admin.

Deployment

Deploy fastapi app by gunicorn+uvicorn or reference https://fastapi.tiangolo.com/deployment/.

Restful API Docs

See restful api docs.

Support this project

AliPay WeChatPay PayPal
PayPal to my account long2ice.

License

This project is licensed under the Apache-2.0 License.

Issues
  • 默默潜水看了你这个项目一段时间了

    默默潜水看了你这个项目一段时间了

    不知道有没有兴趣我们一起开发 我现在做了一个平台也是基于fastapi的 咱们一起做吧

    opened by zky001 15
  • windows 怎么办?

    windows 怎么办?

    安装依赖时报错 RuntimeError: uvloop does not support Windows at the moment

    opened by gcshine 14
  • admin/login POST does not work

    admin/login POST does not work

    Hello, nice project and thanks for sharing. I have successfully deployed and it seems everything is working. I can use the followig command:

    curl -X GET "http://192.168.1.75:8000/admin/site" -H "accept: application/json"

    and get a proper result. But if I use the following:

    curl -X POST "http://192.168.1.75:8000/admin/login" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"username\":\"marco\",\"password\":\"123456\"}"

    I am getting:

    {"msg":"Not Found"}

    which I don't think it is correct. In docker container "fastapi-admin" logs I am finding:

    INFO: 192.168.1.111:41788 - "POST /admin/login HTTP/1.1" 404 Not Found

    opened by mg64ve 13
  • Example - 404 Error

    Example - 404 Error

    Hi, before integrating your solution into my project, I tried to execute your example :

    image

    The application start well :

    image

    And the data are injected into the database :

    image

    But when I try to navigate to 127.0.0.1:8000/admin, I have an 404 error :

    image

    image

    Otherwise, 127.0.0.1:8000/admin/docs works

    My configuration :

    • os: Ubuntu 18.04
    • docker: 19.03.13
    • docker-compose: 1.26.0

    If you need more informations, do not hesitate to ask me.

    Thank you !

    opened by AlexTheByte 12
  • facing issue in running docker

    facing issue in running docker

    Dear Sir,

    File "uvloop/loop.pyx", line 1994, in uvloop.loop.Loop.create_connection app_1 | ConnectionRefusedError: [Errno 111] Connection refused app_1 | app_1 | ERROR: Application startup failed. Exiting. app_1 | INFO: Started server process [1] app_1 | INFO: Waiting for application startup. app_1 | ERROR: Traceback (most recent call last): app_1 | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 526, in lifespan app_1 | async for item in self.lifespan_context(app): app_1 | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 467, in default_lifespan app_1 | await self.startup() app_1 | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 502, in startup app_1 | await handler() app_1 | File "./examples/main.py", line 34, in startup app_1 | redis = await aioredis.create_redis_pool("redis://localhost", encoding="utf8") app_1 | File "/usr/local/lib/python3.9/site-packages/aioredis/commands/init.py", line 188, in create_redis_pool app_1 | pool = await create_pool(address, db=db, app_1 | File "/usr/local/lib/python3.9/site-packages/aioredis/pool.py", line 58, in create_pool app_1 | await pool._fill_free(override_min=False) app_1 | File "/usr/local/lib/python3.9/site-packages/aioredis/pool.py", line 383, in _fill_free app_1 | conn = await self._create_new_connection(self._address) app_1 | File "/usr/local/lib/python3.9/site-packages/aioredis/connection.py", line 111, in create_connection app_1 | reader, writer = await asyncio.wait_for(open_connection( app_1 | File "/usr/local/lib/python3.9/asyncio/tasks.py", line 442, in wait_for app_1 | return await fut app_1 | File "/usr/local/lib/python3.9/site-packages/aioredis/stream.py", line 23, in open_connection app_1 | transport, _ = await get_event_loop().create_connection( app_1 | File "uvloop/loop.pyx", line 2017, in create_connection app_1 | File "uvloop/loop.pyx", line 1994, in uvloop.loop.Loop.create_connection app_1 | ConnectionRefusedError: [Errno 111] Connection refused app_1 | app_1 | ERROR: Application startup failed. Exiting. fastapi-admin_app_1 exited with code 0 (testpy3.9) [email protected]:~/Python-3.9.1/fastapi-admin$ sudo docker-comp

    opened by pvssrikanth 12
  • No values were fetched for this relation

    No values were fetched for this relation

    Hello! I'm using FastApi Admin. It works fine, but in one case I've got a problem. I have ManyToMany Relation in Admin section I can create and delete data, but I can't update data because this error: raise NoValuesFetched( tortoise.exceptions.NoValuesFetched: No values were fetched for this relation, first use .fetch_related())

    Resource: class PageResource(resources.Model): label = "Page" model = Page fields = [ "id", "content", Field(name="type_id", label="Page type", input_=inputs.ForeignKey(model=PageType), ), Field(name="user_id", label="User", input_=inputs.ForeignKey(model=User), ), Field(name="audios", label="Audio", display=displays.InputOnly(), input_=inputs.ManyToMany(model=Audio), ), Field(name="videos", label="Video", display=displays.InputOnly(), input_=inputs.ManyToMany(model=Video), ), ]

    class: class Page(models.Model): """ The Page model """ id = fields.BigIntField(pk=True) content = fields.TextField(null=False) user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField( "models.User", related_name="pages", on_delete=fields.CASCADE) type: fields.ForeignKeyRelation[PageType] = fields.ForeignKeyField( "models.PageType", related_name="pages", on_delete=fields.CASCADE)

    videos: fields.ManyToManyRelation[Video] = fields.ManyToManyField(
        "models.Video", related_name="pages", forward_key="video_id", backward_key="page_id",
        through="page_video"
    )
    
    audios: fields.ManyToManyRelation[Audio] = fields.ManyToManyField(
        "models.Audio", related_name="pages", forward_key="audio_id", backward_key="page_id",
        through="page_audio"
    )
    

    Please help me to manage this problem!

    opened by SantitoSB 9
  • PK values only integer

    PK values only integer

    Hi! It's me again))

    Could you please replace type annotation for pk path params in the admin routes with Union[int, UUID]?

    It would allow to use UUID type for primary keys.

    opened by Addovej 8
  • can´t find setup.py

    can´t find setup.py

    Hi Sir, I don´t understand step 3 of that local example. There is no setup.py, the command "python setup.py install" fails.

    opened by xbln 8
  • setup.py

    setup.py

    can't execute: python setup.py install @https://fastapi-admin-docs.long2ice.cn/get_start.html#run-example-local

    opened by littleforce163 7
  • im not able to create a admin cannot bcrypt this password is saying

    im not able to create a admin cannot bcrypt this password is saying

    mainapp | await instance.save(using_db=db, force_create=True) mainapp | File "/usr/local/lib/python3.9/site-packages/tortoise/models.py", line 927, in save mainapp | await self._pre_save(db, update_fields) mainapp | File "/usr/local/lib/python3.9/site-packages/tortoise/models.py", line 875, in _pre_save mainapp | await asyncio.gather(*listeners) mainapp | File "/usr/local/lib/python3.9/site-packages/fastapi_admin/providers/login.py", line 78, in pre_save_admin mainapp | instance.password = hash_password(instance.password) mainapp | File "/usr/local/lib/python3.9/site-packages/fastapi_admin/utils.py", line 23, in hash_password mainapp | return bcrypt.hashpw(password.encode(), bcrypt.gensalt()).decode() mainapp | AttributeError: 'str' object has no attribute 'decode'

    opened by sakthiRatnam 0
  • [ISSUE OR QUESTION]Make compile is not executed when installing as usual

    [ISSUE OR QUESTION]Make compile is not executed when installing as usual

    We have FastAPI project and our team decided to integrate this lib into it, everything went well until we faced localization issue. As far as pybabel runs only by make compile command, after default installation process, even default localization (.po) files are not compiled to .mo files which i18n is looking for. That's why even default localization doesn't work properly. Is it a bug or am I doing something wrong? Screenshot from pycharm's external libraries screen. Снимок экрана 2022-02-04 в 18 57 10

    opened by dissman 0
  • Enabled prefetched fields

    Enabled prefetched fields

    Enabled prefetching fields from database.

    Use case:

    Table "tables" has foreign key to "schema" table. And admin pages needs to show schema name in the UI instead of its arbitrary object id.

    In this PR, added parsing of 'prefetch' attribute of ComputeFields and these fields are eventually added to obj passed to get_value method.

    class ComputedTableSchema(ComputeField):
        prefetch = ('schema__name',)
    
        async def get_value(self, request: Request, obj: dict):
            return obj["schema__name"]
    

    Another example"

    class ComputedColumnTableName(ComputeField):
        prefetch = ('table__name', 'table__schema__name')
    
        async def get_value(self, request: Request, obj: dict):
            return f'{obj["table__schema__name"]}.{obj["table__name"]}'
    
    @app.register
    class ColumnResource(Model):
        label = "Column"
        model = models.Column
        icon = "fas fa-columns"
        page_pre_title = "column list"
        page_title = "column model"
        fields = [
            "id",
            ComputedColumnTableName(name="table_full_name", label="Table"),
            "name",
            "is_primary",
            "comment",
        ]
    
    opened by artefom 0
  • Ignore empty inputs if field isn't required

    Ignore empty inputs if field isn't required

    Currently, if a form field is not required and leaves it blank, it can raise an error if an empty value string ("") isn't valid, for example, a UUID field.

    This PR fixes this issue by checking if the field is required and if not, checks if its value is empty. If the value is empty, the field is ignored.

    We need to check what happens with other fields type, where the empty value can be another type than an empty string

    opened by fullonic 0
  • Fix datetime search default values

    Fix datetime search default values

    Currently the default value range for Today when searching by a DateTime field is like: DateTime.now() > DateTime.now() which will return almost of the time 0 values. This PR fixed that by using the beginning and the end of the day as range bounds. Also applies the same logic to other default values: Yesterday, Last 7 days, and Last 30 days

    Example of Today: Before: wrong_dt_format Now: fixed_dt_today

    opened by fullonic 0
  • Render fk values inside resource list

    Render fk values inside resource list

    NOTE: This PR depends on #91

    Before: image

    Now: cat_names

    opened by fullonic 0
  • Improve `update` for fk fields

    Improve `update` for fk fields

    Fix #89

    It allows update foreign-key relations following a similar logic implemented with m2m fields. It will render the same obj.__str__() value inside the dropdown menu

    opened by fullonic 0
  • ComputeField display problem

    ComputeField display problem

    Hi! I'm try to use compute field in fastapi admin. def full_name(self) -> str: return self.first_name + ' ' + self.last_name resource description: ComputeField( name="full_name", label="Full name", display=displays.Display(), input_=inputs.DisplayOnly(), ), But I get None in my admin panel. Can you help me? Versions: fastapi==0.68.0 pydantic==1.8.2 tortoise-orm==0.17.3 fasapi-admin==1.0.3

    opened by SantitoSB 2
  • Lack of documentation. Extra actions creating

    Lack of documentation. Extra actions creating

    I don't know maybe I'm blind, or this project don't have a properly-made documentation at all. It more looks like a school project. For example, I don't know how to extend standard create toolbar action, rewrite needed for me module's method. After researches in SOURCE codes, I saw generated methods for auto-handling, but hadn't seen any examples of custom action creation. So, the question is, is there any normal documentation or so? This project seems to be huge and popular enough, you even provide "sponsor" version, but I don't see documentation for coders at all...

    opened by ftelnov 2
Releases(v1.0.3)
python fastapi example connection to mysql

Quickstart Then run the following commands to bootstrap your environment with poetry: git clone https://github.com/xiaozl/fastapi-realworld-example-ap

37 Jan 21, 2022
Lung Segmentation with fastapi

Lung Segmentation with fastapi This app uses FastAPI as backend. Usage for app.py First install required libraries by running: pip install -r requirem

Pejman Samadi 3 Nov 07, 2021
The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.

The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.

Bruno Rocha 97 Jan 25, 2022
FastAPI Admin Dashboard based on FastAPI and Tortoise ORM.

FastAPI ADMIN 中文文档 Introduction FastAPI-Admin is a admin dashboard based on fastapi and tortoise-orm. FastAPI-Admin provide crud feature out-of-the-bo

long2ice 1.1k Feb 11, 2022
JSON-RPC server based on fastapi

Description JSON-RPC server based on fastapi: https://fastapi.tiangolo.com Motivation Autogenerated OpenAPI and Swagger (thanks to fastapi) for JSON-R

147 Jan 29, 2022
api versioning for fastapi web applications

fastapi-versioning api versioning for fastapi web applications Installation pip install fastapi-versioning Examples from fastapi import FastAPI from f

Dean Way 334 Jan 22, 2022
Example app using FastAPI and JWT

FastAPI-Auth Example app using FastAPI and JWT virtualenv -p python3 venv source venv/bin/activate pip3 install -r requirements.txt mv config.yaml.exa

Sander 23 Jan 28, 2022
Backend logic implementation for realworld with awesome FastAPI

Backend logic implementation for realworld with awesome FastAPI

Nik 1.7k Feb 02, 2022
Basic FastAPI starter with GraphQL, Docker, and MongoDB configurations.

FastAPI + GraphQL Starter A python starter project using FastAPI and GraphQL. This project leverages docker for containerization and provides the scri

Cloud Bytes Collection 2 Dec 20, 2021
Publish Xarray Datasets via a REST API.

Xpublish Publish Xarray Datasets via a REST API. Serverside: Publish a Xarray Dataset through a rest API ds.rest.serve(host="0.0.0.0", port=9000) Clie

xarray-contrib 73 Jan 10, 2022
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 375 Feb 02, 2022
Social Distancing Detector using deep learning and capable to run on edge AI devices such as NVIDIA Jetson, Google Coral, and more.

Smart Social Distancing Smart Social Distancing Introduction Getting Started Prerequisites Usage Processor Optional Parameters Configuring AWS credent

Neuralet 108 Jan 24, 2022
A Jupyter server based on FastAPI (Experimental)

jupyverse is experimental and should not be used in place of jupyter-server, which is the official Jupyter server.

Jupyter Server 95 Jan 04, 2022
A minimalistic example of preparing a model for (synchronous) inference in production.

A minimalistic example of preparing a model for (synchronous) inference in production.

Anton Lozhkov 6 Nov 28, 2021
Money Transaction is a system based on the recent famous FastAPI.

moneyTransfer Overview Money Transaction is a system based on the recent famous FastAPI. techniques selection System's technique selection is as follo

2 Apr 27, 2021
官方文档已经有翻译的人在做了,

FastAPI 框架,高性能,易学,快速编码,随时可供生产 文档:https://fastapi.tiangolo.com 源码:https://github.com/tiangolo/fastapi FastAPI 是一个现代、快速(高性能)的 Web 框架,基于标准 Python 类型提示,使用

ApacheCN 27 Jun 27, 2021
A Prometheus Python client library for asyncio-based applications

aioprometheus aioprometheus is a Prometheus Python client library for asyncio-based applications. It provides metrics collection and serving capabilit

106 Jan 17, 2022
Twitter API with fastAPI

Twitter API with fastAPI Content Forms Cookies and headers management Files edition Status codes HTTPExceptions Docstrings or documentation Deprecate

Juan Agustin Di Pasquo 1 Dec 20, 2021
基于Pytorch的脚手架项目,Celery+FastAPI+Gunicorn+Nginx+Supervisor实现服务部署,支持Docker发布

cookiecutter-pytorch-fastapi 基于Pytorch的 脚手架项目 按规范添加推理函数即可实现Celery+FastAPI+Gunicorn+Nginx+Supervisor+Docker的快速部署 Requirements Python = 3.6 with pip in

12 Jan 11, 2022
volunteer-database

This is the official CSM (Crowd source medical) database The What Now? We created this in light of the COVID-19 pandemic to allow volunteers to work t

32 Dec 12, 2021