项目
在 GitHub 查看
kigawas/fastapi-django
关于
FastAPI with Django ORM
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文fastapi-django
FastAPI with Django ORM
More details are here.
Directory hierarchy
$ tree -L 3 -I '__pycache__|.venv|staticfiles' -P '*.py'
.
├── manage.py
├── mysite
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── polls
├── __init__.py
├── adapters
│ └── __init__.py
├── admin.py
├── apps.py
├── migrations
│ ├── 0001_initial.py
│ └── __init__.py
├── models
│ └── __init__.py
├── routers
│ ├── __init__.py
│ ├── choices.py
│ └── questions.py
├── schemas
│ └── __init__.py
└── tests.py
7 directories, 18 files
models: Django ORMsrouters: FastAPI routersschemas: Pydantic modelsadapters: Converting Django ORMs to Pydantic models
Installation
uv sync
Before the first run
Migration
./manage.py migrate
Data insertion
./manage.py shell
>>> from polls.models import Choice, Question
>>> from django.utils import timezone
>>> q = Question(question_text="What's new?", pub_date=timezone.now())
>>> q.save()
Run
$ uvicorn mysite.asgi:fastapp --reload
...
$ ./manage.py collectstatic --noinput # generate static files for django admin
...
$ uvicorn mysite.asgi:application --port 8001 --reload # Django
...
$ curl http://localhost:8000/question/
{"items":[{"question_text":"What's new?","pub_date":"2021-03-29T04:18:54.724432+00:00"}]}%
Mount Django asgi application
# in mysite/settings.py
MOUNT_DJANGO_APP = True
Then http://localhost:8000/django/admin
Tools
FastAPI doc
http://localhost:8000/docs
Django admin
http://localhost:8001/admin
Pre-commit hook
pre-commit install
pre-commit run --all-files
探索相关项目
加载中…