From the course: Django Essential Training

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Introduction to ORMs

Introduction to ORMs

- [Instructor] So far, you've gotten familiarized with the user models, which were completely defined by Django. Now, it's time to understand how to create your own models and how the structure of creating models work. Django uses an object-relational mapping system or ORM to handle database communication and changes. What you need is to write class models that will then be transformed by migrations into database tables. Each class, known as a model, is a database table, and each class attribute is a column. The way we transform a model into a database table is by the creation of migrations. Migrations will have the step-by-step transformation that a database must do to apply the changes made in the code. You've seen that we use the command Migrate to apply migrations to a database. Similarly, we can use the command MakeMigrations to create migrations based on the current code. The process of using a class, defining a model, creating a migration, and applying the migration and the…

Contents