Django

How To Create Django Models

Pinterest LinkedIn Tumblr

Create a model field within models.py file

class Contact(models.Model):
    name = models.CharField(max_length=100)
    email = models.EmailField(max_length=100)
    subject = models.CharField(max_length=100)
    message = models.TextField()
    mobile = models.IntegerField(max_length=180)
    created_on = models.DateTimeField(auto_now_add=True)

Associate with settings.py

INSTALLED_APPS = [
    'contact.apps.ContactConfig',
]

Run migrations command

python manage.py makemigrations

Check Migration

python manage.py showmigrations
python manage.py migrate

Write A Comment