Retrieve the last migration for a custom migration, to load initial data
<p>I created a custom migration "0000_initial_data.py" and I want that to get applied after all the other migrations are done. Though when I try to use ____latest____ in the dependencies I get "dependencies reference nonexistent parent node" error I feel it is trying to find ____latest____ named migration in the folder but it is unable to find. I got an idea of finding the latest migration in myapp/migrations/ using "ls -Art | tail -n 1" which gave me 0001_initial.pyc [pyc] file rather than the latest migration .py file. Though even if I get the name of the latest migration I have to replace in the custom migration file using a shell script like </p>

<pre><code>$ replace '__latest__' 'output of ls -Art' -- 0000_initial_data.py 
</code></pre>

<p>as am automating my deployment. I would like to know the best way to get the latest migration from all myapps in the project and plug my custom migration after it.</p>

<p>Note: using django==1.8.13, ubuntu 14.04, python 2.7</p>

<p>Generally custom migrations are used for changing existing data. If you wanna create new data, I recommend you to put your code inside a management command and run that after all migrations.</p>

python django django-migrations