Recall & Review
beginner
What is the purpose of the <code>Meta</code> class inside a Django model?The <code>Meta</code> class is used to configure model behavior like database table name, ordering, verbose names, and other options without adding fields.Click to reveal answer
beginner
What does the <code>ordering</code> option in a Django model's <code>Meta</code> class do?It defines the default order in which records are returned from the database, e.g.,
ordering = ['name'] sorts by the 'name' field ascending.Click to reveal answer
beginner
How do you change the database table name for a Django model?
Use the
db_table option inside the Meta class, e.g., db_table = 'custom_table_name'.Click to reveal answer
intermediate
What is the use of
verbose_name and verbose_name_plural in Django model Meta?verbose_name sets a human-friendly singular name for the model, and verbose_name_plural sets the plural form. These appear in admin and messages.Click to reveal answer
intermediate
What does setting <code>unique_together</code> in a Django model's <code>Meta</code> class do?It enforces that a combination of two or more fields must be unique together in the database, preventing duplicate pairs.
Click to reveal answer
Which
Meta option changes the default database table name for a Django model?✗ Incorrect
The correct option is
db_table. It sets the exact table name used in the database.What does the
ordering option in a Django model's Meta class control?✗ Incorrect
ordering controls how query results are sorted by default.If you want to make sure two fields together are unique in a Django model, which
Meta option do you use?✗ Incorrect
unique_together enforces uniqueness on a combination of fields.Which
Meta option sets a human-friendly singular name for a Django model?✗ Incorrect
verbose_name is used for a readable singular name in admin and messages.What happens if you do NOT define a
Meta class in a Django model?✗ Incorrect
If
Meta is missing, Django uses default settings for table name and ordering.Explain how the
Meta class in a Django model helps customize the model's behavior.Think about how you can change names, order, and uniqueness without adding fields.
You got /3 concepts.
Describe the difference between
verbose_name and verbose_name_plural in Django model Meta options.Consider how words change when talking about one item versus many.
You got /3 concepts.