From 970117a474b763d1290f30527bbbac39d6a04425 Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Sat, 27 Sep 2025 12:46:38 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Improve=20getting=20started=20do?= =?UTF-8?q?cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3d1dc88..101d856 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ # 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. -It is blazingly fast and has batteries included. +It is *blazingly* fast and comes with batteries included. Features: - Django-like project-layout and -structure -- Django-like settings.py +- Django-like prject-level settings.py - Django-like models via TortoiseORM -- Django-like model.Meta class for model configuration -- Django-like advanced permissions system +- Django-like `Model.Meta` class for model configuration +- Easily convert your models to `pydantic` models via `Model.Schema` - Django-like migrations (makemigrations & migrate) via Aerich - Django-like CLI for interfacing with your projects (startproject, startapp, shell, serve, etc) -- various optional builtin apps -- highly configurable and customizable +- Various optional builtin apps +- Highly configurable and customizable - 100% async ## Getting started @@ -25,6 +25,7 @@ Features: ``` pip install ohmyapi +pip install 'ohmyapi[auth]' # optionally add PyJWT and all necessary crypto deps ohmyapi startproject myproject cd myproject ``` @@ -34,6 +35,7 @@ This will create the following directory structure: ``` myproject/ - pyproject.toml + - README.md - settings.py ``` @@ -63,6 +65,7 @@ myproject/ - models.py - routes.py - pyproject.toml + - README.md - settings.py ``` @@ -94,13 +97,15 @@ router = APIRouter(prefix="/myapp") @router.get("/") 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") async def get(id: int): try: - return await Person.Schema.one(Person.get(pk=id)) + queryset = await Person.get(pk=id) + return await Person.Schema.one(queryset) except DoesNotExist: raise HTTPException(status_code=404, detail="item not found") @@ -128,6 +133,7 @@ myproject/ - migrations/ - myapp/ - pyproject.toml + - README.md - settings.py ``` @@ -156,7 +162,7 @@ ohmyapi shell A builtin auth app is available. 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`: