tortoise / tortoise/tortoise-orm

more further pydantic/serialization options

Open
#315 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion enhancement
Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Is your feature request related to a problem? Please describe.
The current pydantic integration is great but only one way, it's only useful for serializing and sending out data

Describe the solution you'd like
integration for deserializing models as well, this would make integrating with web frameworks that already leverage pydantic (like fastapi) much much easier

more specifically:

  • a way to to make objects linked to the database based on a dict or even directly so classes can be used directly as type hints and fastapi/pydantic figure out the validation and returning of 422 (unprocessable entity) errors so we don't have to do this

  • a way to then save this object to the database (saving the altered fields, primary key or unique key would ofc have to be present and valid for this to work)

Describe alternatives you've considered
doing it manually, it works but isn't great

Additional context
building an api using fastapi for handling the web requests and tortoise is my orm of choice to communicate with the database

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named. Start by locating the existing Pydantic serialization integration and reviewing how Tortoise models are used with FastAPI; define the scope for deserializing dicts or models and saving altered fields when a valid primary or unique key is present.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
backend-api-design, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.