tortoise / tortoise/tortoise-orm

What is the best approach for creating pydantic response models?

Open
#890 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Currently, I am struggling with many problems in creating pydantic response models, because my database has grown a bit and I have a lot of m2m relations, foreign keys, etc. The nested PydanticMeta class becomes more and more a problem for me than a use, manual creation of model responses does not always work, because the m2m field mapping does not work for me as I mentioned in: #887

My question is, do any of you have a proven method / approach in creating pydantic response models?

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

Start by reading issue #887 and the existing guidance around nested PydanticMeta classes and manual response-model mapping. A useful outcome would need to define and document a proven approach for response models involving many-to-many relations and foreign keys.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
databases
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.