ORM for Djangos
The Django ORM maps Python classes called models to database tables, letting you create, query and update rows without writing SQL. QuerySets build lazy, chainable queries with filter, exclude and annotate, relationships use ForeignKey and ManyToManyField, and migrations track and apply schema changes over time.
Stage: Data · Part of the Django roadmap · Last reviewed 19 November 2026
What to learn in ORM
- Define models with fields, relationships and Meta options
- Query data with filter, exclude, get and Q objects
- Aggregate and annotate results using Count and Sum
- Create and apply migrations with makemigrations and migrate
- Write a data migration to transform existing rows
- Explain QuerySet laziness and when the database is actually hit
ORM interview questions
What does it mean that a Django QuerySet is lazy?
Creating or chaining a QuerySet does not touch the database. The SQL runs only when you evaluate it, for example by iterating, slicing with a step, calling list(), len() or exists(). Results are cached on the QuerySet after evaluation.
What is the difference between makemigrations and migrate?
makemigrations inspects your models and writes migration files describing the schema changes. migrate applies those files to the database and records them. The first changes code, and the second changes the database.
Where ORM fits in the Django roadmap
ORM belongs to the Data stage (intermediate level), which takes about 20 hours. ORM and migrations.
Other units in this stage
Back to the full Django roadmap