python django model创建表报错

λ python manage.py migrate TestModel
System check identified some issues:

WARNINGS:
?: (mysql.W002) MySQL Strict Mode is not set for database connection 'default'
HINT: MySQL's Strict Mode fixes many data integrity problems in MySQL, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/3.0/ref/databases/#mysql-sql-mode
Operations to perform:
Apply all migrations: (none)
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

执行 

python manage.py migrate

报错误

  Your models have changes that are not yet reflected in a migration, and so won't be applied.   Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

这个错误是因为你的数据库文件更改需要更新一下

 

先执行下

python manage.py makemigrations 

在执行

python manage.py migrate 

就可以成功执行了

$ python manage.py migrate TestModel # 创建表结构

猜你喜欢

转载自www.cnblogs.com/chengfengchi/p/13398543.html