Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify app dependency in migration

I'm trying to add initial data in Django 1.7 and I've read that it is recommended to use data migrations.

I've created my migration file correctly, called "0001_groups", in which I create few contrib.auth's groups and permissions.

The problem is that it is run before the auth migrations are run.

I went to find out what't the name of the last migration of the auth app, and it's called 0005_alter_user_last_login_null.py. So I tried with:

dependencies = [
    ('auth', '0005_alter_user_last_login_null'),
]

but I get:

KeyError: u"Migration appname.0001_groups dependencies references nonexistent parent node ('auth', '0005_alter_user_last_login_null')"

I've googled that error and it always links to 11 months old fixed bugs of Django.

How can I correctly specify the auth app dependency?

like image 287
Shoe Avatar asked Sep 06 '14 18:09

Shoe


1 Answers

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

dependencies = [
    ('auth', '__latest__'),
]
like image 96
Shoe Avatar answered Oct 03 '22 07:10

Shoe