fastapi-admin is a fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin.

Overview

FastAPI Admin

image image image image

中文文档

Introduction

fastapi-admin is a fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin.

Installation

> pip install fastapi-admin

Requirements

Online Demo

You can check a online demo here.

  • username: admin
  • password: 123456

Or pro version online demo here.

  • username: admin
  • password: 123456

Screenshots

Run examples in local

  1. Clone repo.

  2. Create .env file.

    DATABASE_URL=mysql://root:[email protected]:3306/fastapi-admin
    REDIS_URL=redis://localhost:6379/0
    
  3. Run docker-compose up -d --build.

  4. Visit http://localhost:8000/admin/init to create first admin.

Documentation

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

License

This project is licensed under the Apache-2.0 License.

Comments
  • 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
  • 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
  • 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
  • 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
  • 修改用户时间问题

    修改用户时间问题

    修改用户信息的时候,时间字段出现错误。 tortoise.exceptions.OperationalError: (1292, "Incorrect datetime value: '2021-01-13T00:00:00+00:00' for column 'last_login' at row 1")

    opened by cuiwanjun 7
  • HTTP error 404 while being unauthorized

    HTTP error 404 while being unauthorized

    Hello,

    It is a bit confusing in example app to obtain 404 instead of 401 while not being authorized. Wouldn't it be more correct to return 401 error here: https://github.com/fastapi-admin/fastapi-admin/blob/master/fastapi_admin/depends.py#L73-L73 ?

    opened by radiophysicist 5
  • 本地启动examble报错:/bin/sh -c mkdir -p /fastapi-admin

    本地启动examble报错:/bin/sh -c mkdir -p /fastapi-admin

    ERROR: Service 'app' failed to build: The command '/bin/sh -c mkdir -p /fastapi-admin' returned a non-zero code: 1 抛开权限不说,这里既然用了-c是不是应该把后面的mkdir及其参数用引号包裹起来? /bin/sh -c 'mkdir -p /fastapi-admin' 我该如何修改启动脚本?

    权限问题,我手动创建了/fastapi-admin,并把文件夹属主改为了当前用户

    opened by xflcx1991 5
  • admin app not loading properly

    admin app not loading properly

    When using the sample code, /admin returns 404.

    Here's my main.py:

    from fastapi import FastAPI
    from fastapi_admin.factory import app as admin_app
    from fastapi_admin.site import Site
    from starlette.middleware.cors import CORSMiddleware
    from tortoise.contrib.fastapi import register_tortoise
    
    app = FastAPI()
    
    
    @app.get("/")
    async def root():
        return {"message": "Hello World"}
    
    app.add_middleware(
            CORSMiddleware,
            allow_origins=["*"],
            allow_credentials=True,
            allow_methods=["*"],
            allow_headers=["*"],
            expose_headers=["*"],
        )
    register_tortoise(
        app,
        db_url="sqlite://:memory:",
        modules={"models": ["database.models"]},
        generate_schemas=True,
        add_exception_handlers=True,
    )
    
    app.mount("/admin", admin_app)
    
    @app.on_event('startup')
    async def startup():
        await admin_app.init(
            admin_secret="test",
            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,
            ),
        )
    

    Here's my requirements.txt:

    aiomysql==0.0.21
    aiosqlite==0.16.0
    asyncpg==0.22.0
    bcrypt==3.2.0
    cffi==1.14.5
    click==7.1.2
    colorama==0.4.4
    fastapi==0.63.0
    fastapi-admin==0.3.3
    gunicorn==20.1.0
    h11==0.12.0
    iso8601==0.1.14
    Jinja2==2.11.3
    MarkupSafe==1.1.1
    passlib==1.7.4
    prompt-toolkit==3.0.18
    pycparser==2.20
    pydantic==1.8.1
    PyJWT==2.1.0
    PyMySQL==0.9.3
    pypika-tortoise==0.1.0
    python-dotenv==0.17.1
    python-rapidjson==1.0
    pytz==2020.5
    six==1.15.0
    starlette==0.13.6
    tortoise-orm==0.17.2
    typing-extensions==3.10.0.0
    uvicorn==0.13.4
    wcwidth==0.2.5
    XlsxWriter==1.4.0
    
    
    opened by aminalaee 5
  • 401 Unauthorized on Frontend Part

    401 Unauthorized on Frontend Part

    I've integrated backend part +- successfully - I have nothing on /admin/, getting 404, but have created first Admin user and logged in on the backend site properly. The problem is that I'm typing the same password on frontend part and getting Unauthorized response despite the fact the credentials are correct. Here is logs I'm receiving on backend part:

    INFO:     127.0.0.1:46580 - "OPTIONS /admin/site HTTP/1.1" 200 OK
    INFO:     127.0.0.1:46580 - "GET /admin/site HTTP/1.1" 404 Not Found
    INFO:     127.0.0.1:46586 - "OPTIONS /admin/login HTTP/1.1" 200 OK
    INFO:     127.0.0.1:46586 - "POST /admin/login HTTP/1.1" 401 Unauthorized
    

    How to overcome that? Maybe I'm doing something wrong? Did I miss something? The total process of my installation is like that:

    1. Mounted to existing project - I've added admin model and some models of my apps. Database integration succeed, as well as redis integration. And the creation of the initial user was succeed. I could even login through /admin/login page - but on /admin/ I see only 404 page.
    2. Restful-admin frontend part - I've installed it using yarn and it works good, could even communicate to backend.
    opened by ftelnov 4
  • Admin login redis set() got an unexpected keyword argument 'expire'

    Admin login redis set() got an unexpected keyword argument 'expire'

    // providers/login.py
    // await redis.set(constants.LOGIN_USER.format(token=token), admin.pk, expire=expire)
    TypeError: set() got an unexpected keyword argument 'expire'
    
    opened by Pkittipat 4
  • Bump setuptools from 65.3.0 to 65.5.1

    Bump setuptools from 65.3.0 to 65.5.1

    Bumps setuptools from 65.3.0 to 65.5.1.

    Changelog

    Sourced from setuptools's changelog.

    v65.5.1

    Misc ^^^^

    • #3638: Drop a test dependency on the mock package, always use :external+python:py:mod:unittest.mock -- by :user:hroncok
    • #3659: Fixed REDoS vector in package_index.

    v65.5.0

    Changes ^^^^^^^

    • #3624: Fixed editable install for multi-module/no-package src-layout projects.
    • #3626: Minor refactorings to support distutils using stdlib logging module.

    Documentation changes ^^^^^^^^^^^^^^^^^^^^^

    • #3419: Updated the example version numbers to be compliant with PEP-440 on the "Specifying Your Project’s Version" page of the user guide.

    Misc ^^^^

    • #3569: Improved information about conflicting entries in the current working directory and editable install (in documentation and as an informational warning).
    • #3576: Updated version of validate_pyproject.

    v65.4.1

    Misc ^^^^

    v65.4.0

    Changes ^^^^^^^

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Tabler UI not working?

    Tabler UI not working?

    I have integrated the admin into my project. I was able to create first admin user with /admin/init and see the admin user in the database.

    When I go to 127.0.0.1:8000/admin/login I can see a login page. I enter username and password. I get logged in but see empty page with 404 Not Found.

    I found another ticket which shows that this project is only for admin back-end API. The front-end needs to be installed separately.

    That's OK but in that case README.md is very confusing and it should be changed.

    1. It should remove all screenshots (which suggest that the package comes with full admin UI).
    2. It should clearly say that this project is admin back-end only and has no UI. It should point to the front-end UI repository
    3. It would also be helpful to mention, that GET /init/ page is one time use only - it stops working after creating the first admin user.
    4. Finally, the GET /admin/login page should be removed. It now renders what looks like a regular login page, which makes an impression the project has UI, but logging in leads to 404 and googling leads to a ticket where it says there is no UI and it needs to be installed separately.
    opened by PawelRoman 0
  • Error running dockerfile

    Error running dockerfile

    Good Morning! I cloned your repository and tried to run the dockerfile that comes with it to see how the application works. However, right after the container is initialized with docker compose up -d --build, the container stops and the following error is thrown in its log: image Could you please help me with this? I would love to implement an admin panel in the application I'm building, thanks in advance!

    opened by JhonataAugust0 0
Releases(v1.0.3)
Owner
fastapi-admin
A fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin
fastapi-admin
A high-level app and dashboarding solution for Python

Panel provides tools for easily composing widgets, plots, tables, and other viewable objects and controls into custom analysis tools, apps, and dashboards.

HoloViz 2.5k Jan 03, 2023
EOD (Easy and Efficient Object Detection) is a general object detection model production framework.

EOD (Easy and Efficient Object Detection) is a general object detection model production framework.

383 Jan 07, 2023
An improved django-admin-tools dashboard for Django projects

django-fluent-dashboard The fluent_dashboard module offers a custom admin dashboard, built on top of django-admin-tools (docs). The django-admin-tools

django-fluent 326 Nov 09, 2022
Django application and library for importing and exporting data with admin integration.

django-import-export django-import-export is a Django application and library for importing and exporting data with included admin integration. Featur

2.6k Jan 07, 2023
AaPanel - Simple but Powerful web-based Control Panel

Introduction: aaPanel is the International version for BAOTA panel(www.bt.cn) There have millions servers had installed BAOTA panel since 2014 in Chin

bt.cn 1.4k Jan 09, 2023
An administration website for Django

yawd-admin, a django administration website yawd-admin now has a live demo at http://yawd-admin.yawd.eu/. Use demo / demo as username & passowrd. yawd

Pantelis Petridis 140 Oct 30, 2021
Jazzy theme for Django

Django jazzmin (Jazzy Admin) Drop-in theme for django admin, that utilises AdminLTE 3 & Bootstrap 4 to make yo' admin look jazzy Installation pip inst

David Farrington 1.2k Jan 08, 2023
:honey_pot: A fake Django admin login screen page.

django-admin-honeypot django-admin-honeypot is a fake Django admin login screen to log and notify admins of attempted unauthorized access. This app wa

Derek Payton 907 Dec 31, 2022
Jet Bridge (Universal) for Jet Admin – API-based Admin Panel Framework for your application

Jet Bridge for Jet Admin – Admin panel framework for your application Description About Jet Admin: https://about.jetadmin.io Live Demo: https://app.je

Jet Admin 1.3k Dec 27, 2022
手部21个关键点检测,二维手势姿态,手势识别,pytorch,handpose

手部21个关键点检测,二维手势姿态,手势识别,pytorch,handpose

Eric.Lee 321 Dec 30, 2022
A platform used with frabit-server and frabit

A platform used with frabit-server and frabit

FrabitTech 1 Mar 03, 2022
django-admin fixture generator command

Mockango for short mockango is django fixture generator command which help you have data without pain for test development requirements pip install dj

Ilia Rastkhadiv 14 Oct 29, 2022
Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap.

Xadmin Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap. Liv

差沙 4.7k Dec 31, 2022
With Django Hijack, admins can log in and work on behalf of other users without having to know their credentials.

Django Hijack With Django Hijack, admins can log in and work on behalf of other users without having to know their credentials. Docs 3.x docs are avai

1.2k Jan 02, 2023
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.6k Jan 02, 2023
Django Smuggler is a pluggable application for Django Web Framework that helps you to import/export fixtures via the automatically-generated administration interface.

Django Smuggler Django Smuggler is a pluggable application for Django Web Framework to easily dump/load fixtures via the automatically-generated admin

semente 373 Dec 26, 2022
Freqtrade is a free and open source crypto trading bot written in Python

Freqtrade is a free and open source crypto trading bot written in Python. It is designed to support all major exchanges and be controlled via Telegram. It contains backtesting, plotting and money man

20.2k Jan 02, 2023
Responsive Theme for Django Admin With Sidebar Menu

Responsive Django Admin If you're looking for a version compatible with Django 1.8 just install 0.3.7.1. Features Responsive Sidebar Menu Easy install

Douglas Miranda 852 Dec 02, 2022
A configurable set of panels that display various debug information about the current request/response.

Django Debug Toolbar The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/respons

Jazzband 7.3k Dec 31, 2022
GFPGAN is a blind face restoration algorithm towards real-world face images.

GFPGAN is a blind face restoration algorithm towards real-world face images.

Applied Research Center (ARC), Tencent PCG 25.6k Jan 04, 2023