Exploring Django ORM, Models, and Migrations
In Chapter 1, we saw how to create a Django project and integrate Views into the project. All the responses in the Views were static and we didn’t see how to implement any code to get dynamic responses using databases.
In this chapter, we shall see how to integrate a PostgreSQL database into our Django project and the support Django provides out of the box to work with models and databases. If you have worked with relational database management systems (RDBMSs) before, you will know how painful it is to perform migrations whenever the schema is updated. However, Django provides migration support out of the box, which abstracts all the intricacies under two management commands.
After that, we’ll learn a few best practices while working with Django models and how to check for performance optimizations with large database tables. Finally, we’ll check out the newest feature that was introduced in Django 4.1: Async...