Django learning (day 4: ORM&Model) Modelsettingsmigrate and makemigrations

Django learning (day 4: ORM&Model) Modelsettingsmigrate and makemigrations

ORM is a kind of programming technology used to realize the conversion between data of different types of systems in object-oriented programming languages.


from django.utils import timezone

# Create your models here.

class UserInfo(models.Model):
    js_id = models.CharField(max_length=50,verbose_name=u'简书id')
    wx_id = models.CharField(max_length=20,verbose_name=u'WeChat id')
    nick_name = models.CharField(max_length=20, verbose_name=u"group nickname")
    gender = models.CharField(max_length=1, verbose_name=u"Gender")
    age = models.IntegerField(verbose_name=u"age")
    major = models.CharField(max_length=30, verbose_name=u"professional")
    job = models.CharField(max_length=20, verbose_name=u"vocation")
    hobby = models.CharField(max_length=50, verbose_name=u"interests and hobbies")
    level = models.CharField(max_length=5, verbose_name=u"Python basics")
    is_new = models.CharField(max_length=1, verbose_name=u"Is there any other programming language foundation")
    learn_time = models.CharField(max_length=10, verbose_name=u"learning time")
    has_book = models.CharField(max_length=100, verbose_name=u"Are there any Python related books")
    creat_time = models.DateTimeField(, verbose_name=u"create time")


    'default': {
        'PASSWORD': '123456',
        'PORT': '3306'

migrate and makemigrations

  • Use [makemigrations] to create a change script for the database table
  • Use [migrate] to perform data table changes
Reference: Django learning (day 4: ORM&Model) Modelsettingsmigrate and makemigrations-Cloud + Community-Tencent Cloud