tortoise / tortoise/tortoise-orm

About multi-databases and multi-apps configuration

Open
#682 0 comments 0 reactions 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

TORTOISE_ORM = {
    "connections": {"default": MYSQL_URL,"admin": ADMIN_MYSQL_URL},
    "apps": {
        "app1": {
            "models": [...],
            "default_connection": MYSQL_URL,
        },
        "app2": {
            "models": [...],
            "default_connection": ADMIN_MYSQL_URL,
        },
    },
}

in method - get_related_model(related_app_name, related_model_name) of tortoise/init.py ,related_app_name can only get 'models',can't get app_label 'app1' or app_label 'app2',so it report error! For making it run correctly I changed 'related_app_name' to 'app_name'. Sorry,I don't know if my Chinglish is clear.

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 in tortoise/init.py at get_related_model(related_app_name, related_model_name) and trace how app labels are resolved for the shown multi-database configuration. Reproduce the relation lookup with app1 and app2, then verify that related models resolve under their configured app labels without breaking existing single-app behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, python
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.