1.先创建一个app
python manage.py startapp myblog
一定要记得在setting.py中添加新建的app
class Person(models.Model):
name = models.CharField(max_length=150)
email = models.EmailField()
update_time = models.DateTimeField(auto_now=True)
create_time = models.DateTimeField(auto_now_add=True)
null_test = models.CharField(max_length=200, null=True)
black_test = models.CharField(max_length=200, blank=True)
2.调试
修改manage.py 进行debug调试
print(sys.argv)
sys.argv = ['manage.py','migrate']
execute_from_command_line(sys.argv)
修复migrations
先执行 :
python manage.py makemigrations myblog
然后执行:
python manange.py migrate
按顺序执未同步的 migrations
1.更改migrations中文件的问题
2.删除migrations文件推倒重来