from django.db import models
class YourModel(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
email = models.EmailField()
created_at = models.DateTimeField(auto_now_add=True)
- Import the necessary modules from Django.
- Create a class named
YourModel
which inherits from models.Model
. - Define fields within the class using Django's field types like
CharField
, IntegerField
, EmailField
, and DateTimeField
. name
is a field of type CharField
with a maximum length of 100 characters.age
is a field of type IntegerField
.email
is a field of type EmailField
.created_at
is a field of type DateTimeField
which automatically sets the current date and time when an instance is created.
```