This lesson will show you what steps to take to before making migrations, You’ll learn how to create a new Django project, create models and how to make migrations from models.
Creating Django Migrations
00:01 Let’s have a look at creating migrations. To create migrations, you’ll need a Django project. Let’s create one now. I’ve made a new directory and I’m installing Django into a new virtual environment.
And there using the
tree command, you can see the structure of the files and directories that we have so far. You can notice that at the moment our
migrations/ folder inside
historical_data/ is empty, so next up it will be time to create the model that we be working with and install the
historical_data app into Django.
First up, you’re adding
'historical_data' to the
INSTALLED_APPS in Django’s
settings.py file. One thing I’ve gotten in the habit of doing is putting a comment to separate out third-party apps and local ones I’ve been working on because later on when things get a little more complicated, it can make it clearer to see what’s happening.
You can optionally add the name of the app. This will make migrations solely for the app in question and can simplify debugging later on. Now the migration has been done and if we look again at the structure of our files and directories, we can see that our
migrations/ folder contains the migration.
Become a Member to join the conversation.