Search code examples
djangodjango-south

South custom models location


I have quite a big django project which has a lot of applications and a lot of models. In order to avoid circular imports several models modules must be used:

app/models.py
app/models_add.py
app/models_aux.py

and so on. Each time I have to make a migration I have to write

from app.models_add import Model

in the app/models.py in order for South to track the model's changes. This seems to be quite annoying because there are a lot of changes in models.

The question is: is there a way to point South which modules/files to track?


Solution

  • You could try setting the app_label on the Meta class of your model.

    class Meta:
        app_label = "app"
    

    Also try setting your directory structure to:

    app/models/__init__.py
    app/models/add.py
    

    That should tell everything to initialize properly. This is what I recently did, but for backwards compatibility in other areas of my project I import everything in models/__init__.py