Home > Net >  In case of Django model,
In case of Django model,

Time:01-09

In the django code in order to make a model,

for example,

class Student(models.Model):
    name = models.CharField(max_length = 200) 

Why models.CharField(max_length = 200). Why can't we write only name=CharField(max_length = 200)

CodePudding user response:

You can. You should only import that field in the scope, for example with:

from django.db import models
from django.db.models import CharField  #            
  •  Tags:  
  • Related