📝 Improve getting started docs
This commit is contained in:
parent
8d486001b6
commit
970117a474
1 changed files with 17 additions and 11 deletions
28
README.md
28
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`:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue