make makemigrations work again


In Django, the recommended standard is to push the migrations folder of (an app) also to git.
Initially I never used to push migration files to GitHub and I ended up having to do python make migrations
as well as python manage.py migrate
on the server - whether it was manually or via a pipeline.
There was one common pitfall to this which I stumbled on many times only to figure it out later - this post is to remind me of how to come out of that pit.
python mange.py makemigrations
would always say “No changes detected” even when you had a model in a brand new app.
Note: This is only relevant to new Django ‘apps’ created (or pulled from Git) - if you had already done makemigrations and migrate on an app previously and it worked then running the same for the second time would work. The reason why it doesn’t work for the first time is because Django looks for a migrations folder and the __init__.py
file in the migrations folder for makemigrations to work.
Goto to the app, say it be booking and create a migrations folder and create an empty __init__.py
file in it. Now run python mange.py makemigrations
, it should work as expected.
cd booking
mkdir migrations
cd migrations
touch __init__.py
cd ../..
python manage.py makemigrations
python manage.py migrate
Subscribe to my newsletter
Read articles from Anjanesh Lekshminarayanan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Anjanesh Lekshminarayanan
Anjanesh Lekshminarayanan
I am a web developer from Navi Mumbai. Mainly dealt with LAMP stack, now into Django and getting into Laravel and Google Cloud. TensorFlow in the near future. Founder of nerul.in and gaali.in