Why aerich init-db throw an tortoise.exceptions.Configuration error: DB configuration not initialised?

319 views Asked by At

I have to run a project using aerich and tortoise to work with postgresql. The model files are located in the project root, in the models.py file. The configuration is in the root of the project, in the settings.py file. I run aerich init -t settings.TORTOISE_ORM and it works fine, creating an empty migrations/models folder.

But when I then run aerich init-db I get the error tortoise.exception.ConfigurationError: DB configuration not initialised. Make sure to call Tortoise.in it with a valid configuration before attempting to create connections. My TORTOISE_ORM:

TORTOISE_ORM = {
    "connections": {"default": db_url},
    "apps": {
        "models": {
            "models": ["app.models", "aerich.models"],
            "default_connection": "default",
        },
    },
}
1

There are 1 answers

1
Syrus Ironseat On
  1. try delete 'migrations' folder
  2. delete tables in your database
  3. make sure your 'app.models'path does exist