[Solved]-Specify app dependency in migration


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


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

dependencies = [
    ('auth', '__latest__'),


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__")]

Leave a comment