Complete the code to define a primary key field in a Django model.
class Product(models.Model): id = models.[1](primary_key=True)
The AutoField is used to create an auto-incrementing primary key in Django models.
Complete the code to set a custom field as the primary key in a Django model.
class Employee(models.Model): employee_id = models.[1](primary_key=True, max_length=10)
To use a string as a primary key, CharField with primary_key=True is used.
Fix the error in the model definition to correctly define a primary key.
class Order(models.Model): order_number = models.IntegerField() [1] = models.AutoField(primary_key=True)
The primary key field should have a valid variable name like id to avoid conflicts and follow Django conventions.
Fill both blanks to create a model with a custom primary key and a regular field.
class Category(models.Model): [1] = models.[2](primary_key=True, max_length=20) name = models.CharField(max_length=100)
id when a custom key is intended.Using code as the field name and CharField with primary_key=True defines a custom string primary key.
Fill all three blanks to create a model with an auto-increment primary key, a foreign key, and a text field.
class Comment(models.Model): [1] = models.[2](primary_key=True) post = models.[3]('Post', on_delete=models.CASCADE) content = models.TextField()
The id field uses AutoField as primary key. The post field is a ForeignKey to the Post model.