tortoise / tortoise/tortoise-orm
Mongoose-like global model registration [Feature request]
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Problem
Currently, initializing Tortoise ORM requires manually listing each module path containing models:
await Tortoise.init(
db_url="...",
modules={"models": ["app.models.user", "app.models.post"]},
)
This manual setup is tedious and error-prone, especially in larger applications.
Proposal
In Mongoose, once a model is imported, it’s automatically registered. Can something similar be implemented in Tortoise?
Alternatives
Yeah, one can loop over the models folder and add the files. But it seems too crude and introduces extra boilerplate for every project.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing Tortoise.init and the current model-module registration flow. Compare the proposed behavior with Mongoose’s import-time registration, then determine the scope and expected behavior for models imported without listing module paths. Done should include an agreed design and tests covering automatic registration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100