From the course: Django Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Introduction to ORMs - Django Tutorial
From the course: Django Essential Training
Introduction to ORMs
- 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, make migrations to create migration space on the current code, the process of using a class, defining a model, creating a…