Complete the code to set the database table name for the model.
class Product(models.Model): name = models.CharField(max_length=100) class Meta: db_table = [1]
The db_table option sets the exact database table name. Here, "product_table" is the correct table name string.
Complete the code to order the model records by the 'created' field descending.
class Article(models.Model): title = models.CharField(max_length=200) created = models.DateTimeField() class Meta: ordering = [[1]]
To order descending by a field, prefix the field name with a minus sign inside the ordering list.
Fix the error in the Meta class to make the model abstract.
class BaseModel(models.Model): created = models.DateTimeField(auto_now_add=True) class Meta: [1] = True
The correct Meta option to make a model abstract is abstract = True.
Fill both blanks to set the verbose name and plural verbose name for the model.
class Customer(models.Model): name = models.CharField(max_length=100) class Meta: verbose_name = [1] verbose_name_plural = [2]
verbose_name is the singular name, and verbose_name_plural is the plural form used in admin and elsewhere.
Fill all three blanks to create a unique constraint on 'email' and 'username' fields with a custom name.
class UserProfile(models.Model): email = models.EmailField() username = models.CharField(max_length=50) class Meta: constraints = [ models.UniqueConstraint(fields=[[1], [2]], name=[3]) ]
The UniqueConstraint requires a list of field names and a name string for the constraint.