DJANGO 5 · 15 QUESTIONS · ABOUT 12 MINUTES

One page, eleven queries.

Django's ORM makes the database feel like Python, which is exactly how slow pages and surprise queries sneak in. Fifteen questions on models, QuerySets, views, templates and forms, each explained. No sign-up, nothing saved.

Start the Django test
for book in Book.objects.all():    print(book.author.name)# 10 books
SQL queries11
QUESTION 1 / 15 · QUERYSETSEasy

How many database queries does this run?

books = Book.objects.filter(year__gte=2020)books = books.exclude(title="")books = books.order_by("title")

What this Django test measures, in short

This test checks whether you can predict what Django does behind the scenes: when a QuerySet actually hits the database and how many times, how model fields and relations behave, how URLs resolve, how templates escape and handle missing values, and how forms and CSRF protection work.

Questions assume Django 5 with default settings. Django REST Framework isn't covered. The questions are our own and not standardised, so treat the result as a knowledge check, not a certification.

By What's Your IQ · Reviewed 4 Oct 2026
Format
15 questions on what Django does, 4 options each
Topics
Models, QuerySets, views and URLs, templates, forms and security
Assumes
Comfortable Python and basic SQL
Framework
Created at a Kansas newspaper; open-sourced 2005
QUESTION 4, WITH THE SQL SHOWING

Count the queries

Following a foreign key on each row triggers a fresh query per row, the N+1 problem. Pick a strategy and a page size, and see what actually reaches the database.

Books on page
books = Book.objects.all()for b in books: print(b.author.name)
11queriesGrows with every row: 10 books, 11 queries.
SQL LOG
1SELECT … FROM book2SELECT … FROM author WHERE id = 13SELECT … FROM author WHERE id = 24SELECT … FROM author WHERE id = 35SELECT … FROM author WHERE id = 46SELECT … FROM author WHERE id = 1… 4 more author lookups11SELECT … FROM author WHERE id = 2
LET THE DATABASE DO IT

Correct in tests, wrong under load

FRAGILE
for a in Author.objects.all(): n = a.book_set.count() print(a.name, n)
IDIOMATIC
authors = Author.objects.annotate( n=Count("book"))for a in authors: print(a.name, a.n)

Counting per row inside a loop is N+1 again. annotate(Count()) gets every count in one GROUP BY query.

"Perfectionists with deadlines"Django's tagline since the startBuilt in a newsroom where stories had to ship the same day, it bundles the admin, ORM, auth and forms so you don't assemble them yourself.1
2003 → 2005A newspaper's in-house tool. Adrian Holovaty and Simon Willison built it at the Lawrence Journal-World; it was open-sourced in 2005 and named after guitarist Django Reinhardt.1
20081.0 and a foundation. Django 1.0 shipped, and the Django Software Foundation was set up to steward it.2
2019 · 3.0Going async. ASGI support arrived, followed by async views in 3.1 and async ORM methods later.2
Every 8 monthsA predictable release train. A new feature release about every eight months, with an LTS every third release.2
  1. Django Software Foundation. FAQ: General. docs.djangoproject.com.
  2. Django Software Foundation. Download and supported versions; release notes. djangoproject.com.

Where to go next

You can count the queries. How do you reason?

Our full IQ test measures the logic and working memory behind good code: 60 questions across four domains, about 30 minutes.

Take the full IQ test