django-models Getting started with django-models Installation or Setup


Generally, each model maps to a single database table.We to write the field type,limits,size,etc in file of the app. This will create the necessary table and fields in the database.

'''    '''
from django.db import models
    class table_name(models.Model):
        field_name= models.field_type(conditions)

Next we need to inform Django in about the app which will be using this model.

    '''  ''''
    #...    ]

We are almost done. Next we need to migrate this app so that database tables are created. In terminal type the following:

python migrate

migrate will create the necessary databases by checking the app_installed in the

By makemigrations, Django will know the changes that are made to the models.

python makemigrations

That's it. Your database is created and you can see the schema in the terminal

python sqlmigrate app_name 0001