Explanation: models.Model: This is the base class for all Django models. Field types: Django provides various field types to represent different kinds of data. Some common field types include: CharField: Stores a fixed-length string. TextField: Stores a long text. IntegerField: Stores an integer. BooleanField: Stores a boolean value (True or False). DateField: Stores a date. DateTimeField: Stores a date and time. FloatField: Stores a floating-point number. DecimalField: Stores a decimal number with specified precision. EmailField: Validates email addresses. URLField: Validates URLs. Relationships: Django supports various relationships between models, including: ForeignKey: Represents a one-to-many relationship. ManyToManyField: Represents a many-to-many relationship..
from django.db import models
class MyModel(models.Model):
char_field = models.CharField(max_length=100)
text_field = models.TextField()
integer_field = models.IntegerField()
boolean_field = models.BooleanField()
date_field = models.DateField()
datetime_field = models.DateTimeField()
float_field = models.FloatField()
decimal_field = models.DecimalField(max_digits=10, decimal_places=2)
email_field = models.EmailField()
url_field = models.URLField()
foreign_key_field = models.ForeignKey('OtherModel', on_delete=models.CASCADE)
many_to_many_field = models.ManyToManyField('OtherModel')