1.在models.py文件中添加代码

class notice(models.Model):
    notice_title = models.CharField(max_length=255)
    notice_content = models.TextField()
    notice_user = models.CharField(max_length=20)
    notice_user_id = models.IntegerField(max_length=11)
    notice_time = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.notice_title

2.执行python manage.py makemigrations RRMS

 

3.查看迁移将运行的SQL:python manage.py sqlmigrate RRMS 0001

4.迁移数据,数据库中创建这些模型表:python manage.py migrate

 

posted on 2019-01-10 16:10  曹婷婷  阅读(245)  评论(0编辑  收藏  举报