Recall & Review
beginner
What is a Django model?
A Django model is a Python class that represents a database table. It defines the structure of stored data using fields.Click to reveal answer
beginner
How do you define a text field in a Django model?
Use
models.CharField(max_length=...) for short text or models.TextField() for longer text without a length limit.Click to reveal answer
beginner
What does
models.IntegerField() represent in a Django model?It represents a field that stores integer numbers in the database.
Click to reveal answer
intermediate
Why do you need to specify
max_length in CharField?Because
CharField stores variable-length strings, max_length sets the maximum allowed characters to save space and enforce limits.Click to reveal answer
intermediate
What is the purpose of the
primary_key=True argument in a Django model field?It marks that field as the unique identifier for each record in the database table.
Click to reveal answer
Which Django field type would you use to store a date?
✗ Incorrect
Use
models.DateField() to store dates in Django models.What argument must you provide to
CharField?✗ Incorrect
max_length is required to limit the size of the string.Which field type allows storing large text without length limit?
✗ Incorrect
TextField is used for large text data.How do you mark a field as the primary key in a Django model?
✗ Incorrect
Use
primary_key=True to set a field as the unique identifier.What does
models.BooleanField() store?✗ Incorrect
BooleanField stores True or False values.Explain how to define a Django model with at least three different field types.
Think about how a model maps to a database table with columns.
You got /4 concepts.
Describe why specifying field types and options is important when defining Django models.
Consider how data structure and rules affect storage and retrieval.
You got /4 concepts.