Django Models & ORM Flashcards
6 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 6 Django Models & ORM flashcards as text
What does the `unique=True` argument on a model field enforce?
Answer: That no two rows can have the same value for that field
Setting unique=True creates a UNIQUE constraint in the database, ensuring no two model instances share the same field value.
Which abstract base class makes a model function as an abstract base, not creating its own database table?
Answer: Setting abstract = True in Meta
Setting abstract = True in the model's Meta class tells Django not to create a database table for that model; subclasses get their own tables with inherited fields.
What does the `null=True` argument on a Django model field do?
Answer: Allows the field to store NULL in the database
null=True allows the database column to store a NULL value; for string-based fields, Django convention prefers blank=True with an empty string instead.
Which Django ORM method deletes all objects matching a QuerySet?
Answer: QuerySet.delete()
Calling delete() on a QuerySet removes all matching objects from the database in an efficient bulk DELETE SQL statement.
What is a Django migration squash used for?
Answer: Combining multiple migrations into a single migration file to reduce history
Squashing migrations uses python manage.py squashmigrations to merge a range of migrations into one, speeding up fresh database setups.
Which field option sets the default value for a Django model field?
Answer: default=
The default= argument provides a value used when no value is supplied for the field, which can be a constant or a callable.
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