Django Flashcards
7 cards from real Django practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Django flashcards as text
Which Django command applies pending database migrations to the database?
Answer: python manage.py migrate
The migrate command applies migration files to the database schema.
In a Django model, which field type is best for storing a large block of multi-line text?
Answer: TextField
TextField stores unbounded multi-line text, unlike CharField which requires max_length.
What does the Django ORM method filter() return?
Answer: A QuerySet
filter() returns a lazy QuerySet that can be further chained or evaluated.
Which decorator restricts a view to logged-in users in Django?
Answer: @login_required
@login_required from django.contrib.auth.decorators redirects anonymous users to the login page.
What is the purpose of Django's {% csrf_token %} template tag?
Answer: Protect POST forms from cross-site request forgery
It inserts a hidden token that Django validates to prevent CSRF attacks on form submissions.
Which setting controls whether detailed error pages are shown to users?
Answer: DEBUG
DEBUG should be False in production to avoid leaking sensitive error details.
How do you retrieve a single object or raise a 404 in a Django view?
Answer: get_object_or_404()
get_object_or_404() from django.shortcuts returns the object or raises Http404 if not found.
Written and edited by Nathan Beja, founder of Practice Test Geeks, with AI assistance. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Editorial policy