编辑models.py
from django.db import models
class Article(models.Model):
title = models.CharField("标题", max_length=30)
writer = models.CharField("作者", max_length=10)
content = models.TextField()
create_date = models.DateField(auto_now_add=True)
update_date = models.DateField(auto_now=True)
is_show = models.BooleanField(default=False)
class Meta:
db_table = ‘article‘
def __str__(self):
return self.title
具体规则见:https://docs.djangoproject.com/en/1.11/topics/db/models/
加上我们的app
把新数据迁移工具 (migrations)
$ python manage.py makemigrations --name changed_my_model your_app_label
把新数据迁移到数据库
$ python manage.py migrate
原文:http://www.cnblogs.com/zsjblog/p/7747767.html