[Solved]-Specify app dependency in migration

3👍

You’re using 1.7 but looking at the master source tree. See this and try 0001_initial.

20👍

I’ve found out that you can reference the last migration with __latest__:

dependencies = [
    ('auth', '__latest__'),
]
👤Shoe

0👍

In my case, I wanted to depend on the very first migration of whatever the django.conf.setting.AUTH_USER_MODEL is set to, so that I don’t have to hard-code the app name in my code.

The following will do just that:

dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]

which is equivalent to:

dependencies = [(settings.AUTH_USER_MODEL.rsplit(".")[0], "__first__")]
👤smac89

Leave a comment