[Answered ]-Django makemigrations does not create models by order in models.py

2👍

The order in which you place your models in your models.py matters if and only if one of them references another as a ForeignKey. In such a situation the order is important and you will find the the migration does preserve the order.

What’s really important is not what shows up when you do manage.py makemigrations but what happens when you do manage.py migrate there django usually figures out the correct order. If at anytime you feel that you want to control the order in which tables are created, you are free to edit the migration file (even though this is not really needed)

👤e4c5

Leave a comment