2. Models and Migrations
Overview
This chapter introduces you to the concept of databases and their importance in building web applications. You will start by creating a database using an open-source database visualization tool called SQLite DB Browser. You will then perform some basic Create Read Update Delete (CRUD) database operations using SQL commands. Then, you will learn about Django's Object Relational Mapping (ORM), using which your application can interact and seamlessly work with a relational database using simple Python code, eliminating the need to run complex SQL queries. You will learn about models and migrations, which are a part of Django's ORM, that are used to propagate database schematic changes from the application to the database, and also perform database CRUD operations. Toward the end of the chapter, you will study the various types of database relationships and use that knowledge to perform queries across related records.