📝 Improve getting started docs

This commit is contained in:
Brian Wiborg 2025-09-27 12:46:38 +02:00
parent 8d486001b6
commit 970117a474
No known key found for this signature in database

View file

@ -1,22 +1,22 @@
# OhMyAPI # OhMyAPI
> OhMyAPI == Application scaffolding for FastAPI+TortoiseORM. > Django-flavored application scaffolding and management layer around FastAPI+TortoiseORM.
OhMyAPI is a Django-flavored web-application scaffolding framework. OhMyAPI is a Django-flavored web-application scaffolding framework and management layer.
Built around FastAPI and TortoiseORM, it 100% async. Built around FastAPI and TortoiseORM, it 100% async.
It is blazingly fast and has batteries included. It is *blazingly* fast and comes with batteries included.
Features: Features:
- Django-like project-layout and -structure - Django-like project-layout and -structure
- Django-like settings.py - Django-like prject-level settings.py
- Django-like models via TortoiseORM - Django-like models via TortoiseORM
- Django-like model.Meta class for model configuration - Django-like `Model.Meta` class for model configuration
- Django-like advanced permissions system - Easily convert your models to `pydantic` models via `Model.Schema`
- Django-like migrations (makemigrations & migrate) via Aerich - Django-like migrations (makemigrations & migrate) via Aerich
- Django-like CLI for interfacing with your projects (startproject, startapp, shell, serve, etc) - Django-like CLI for interfacing with your projects (startproject, startapp, shell, serve, etc)
- various optional builtin apps - Various optional builtin apps
- highly configurable and customizable - Highly configurable and customizable
- 100% async - 100% async
## Getting started ## Getting started
@ -25,6 +25,7 @@ Features:
``` ```
pip install ohmyapi pip install ohmyapi
pip install 'ohmyapi[auth]' # optionally add PyJWT and all necessary crypto deps
ohmyapi startproject myproject ohmyapi startproject myproject
cd myproject cd myproject
``` ```
@ -34,6 +35,7 @@ This will create the following directory structure:
``` ```
myproject/ myproject/
- pyproject.toml - pyproject.toml
- README.md
- settings.py - settings.py
``` ```
@ -63,6 +65,7 @@ myproject/
- models.py - models.py
- routes.py - routes.py
- pyproject.toml - pyproject.toml
- README.md
- settings.py - settings.py
``` ```
@ -94,13 +97,15 @@ router = APIRouter(prefix="/myapp")
@router.get("/") @router.get("/")
async def list(): async def list():
return await Person.Schema.many.from_queryset(Person.all()) queryset = await Person.all()
return await Person.Schema.many.from_queryset(queryset)
@router.get("/:id") @router.get("/:id")
async def get(id: int): async def get(id: int):
try: try:
return await Person.Schema.one(Person.get(pk=id)) queryset = await Person.get(pk=id)
return await Person.Schema.one(queryset)
except DoesNotExist: except DoesNotExist:
raise HTTPException(status_code=404, detail="item not found") raise HTTPException(status_code=404, detail="item not found")
@ -128,6 +133,7 @@ myproject/
- migrations/ - migrations/
- myapp/ - myapp/
- pyproject.toml - pyproject.toml
- README.md
- settings.py - settings.py
``` ```
@ -156,7 +162,7 @@ ohmyapi shell
A builtin auth app is available. A builtin auth app is available.
Simply add `ohmyapi_auth` to your INSTALLED_APPS and define a JWT_SECRET in your `settings.py`. Simply add `ohmyapi_auth` to your INSTALLED_APPS and define a JWT_SECRET in your `settings.py`.
Remember to `makemigrations` and `migrate` for the auth tables to be created in the database. Remember to `makemigrations` and `migrate` for the necessary tables to be created in the database.
`settings.py`: `settings.py`: