Articles → DJANGO → Create your first model in Django

Create your first model in Django






Steps of creating the model






<python_path>\python manage.py startapp <module_name>




from django.db import models

# Create your models here.
class MyNewScreen(models.Model):
    name = models.CharField(max_length = 120)
    def __str__(self):
        return self.name







Click to Enlarge



from django.contrib import admin

# Register your models here.
from .models import MyNewScreen

admin.site.register(MyNewScreen)




<python path>\python manage.py makemigrations
<python path>\python manage.py migrate



Output





Click to Enlarge




Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, December 30, 2019
 
Updated On  -  Thursday, January 16, 2020

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250