create models in django
# Import necessary modules
from django.db import models
# Define a Django model called 'Person'
class Person(models.Model):
# Define a CharField for the person's first name with a maximum length of 30 characters
first_name = models.CharField(max_length=30)
# Define a CharField for the person's last name with a maximum length of 30 characters
last_name = models.CharField(max_length=30)
# Define an EmailField for the person's email address
email = models.EmailField()
# Define an IntegerField for the person's age
age = models.IntegerField()
# Define a BooleanField for the person's status indicating whether they are active or not
is_active = models.BooleanField(default=True)
This example demonstrates the creation of a Django model named 'Person'. The model has five fields:
first_name
: A character field with a maximum length of 30 characters to store the person's first name.last_name
: A character field with a maximum length of 30 characters to store the person's last name.email
: An email field to store the person's email address.age
: An integer field to store the person's age.is_active
: A boolean field with a default value of True, indicating whether the person is active or not.