Using migrations

It is not true that once you have created your database structure, it won't change in the future. As development happens iteratively, you can get updates on the business requirements in the development process and you will need to perform database schema changes along the way. With the Django migrations, you don't need to change the database tables and fields manually, as most of it is done automatically using the command-line interface.

Getting ready

Activate your virtual environment in the command-line tool.

How to do it…

To create the database migrations, take a look at the following steps:

  1. When you create models in your new demo_app app, you need to create an initial migration that will create the database tables for your app. ...

Get Web Development with Django Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.