Django Models (part 3)

The first, you create a app in your project have name is Blog

$ python manage.py startapp blog

Go to settings.py file and insert code in INSTALLED_APPS:

INSTALLED_APPS = [
'blog',
]

and now, you can create model in models.py file (belong to blog app):

from django.db import models
# all model inhert from Model
from django.db.models import Model
# Create your models here.
class PostModel(Model):
pass

and run cmd:

$ python manage.py makemigrations # every time you change models.py
$ python manage.py migrate

You just create a new file inside of this migrations folder.

ID field will get auto, so you dont need have to create it.

Awesome, if you want learn more, you can see documentations at here:

See you next part ✌️

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.