You are trying to add the field 'create_time' with 'auto_now_add=True' to video without a default...

You are trying to add the field 'create_time' with 'auto_now_add=True' to video without a default; the database needs something to populate existing

rows.

1) Provide a one-off default now (will be set on all existing rows)

2) Quit, and let me add a default in models.py

Select an option: 1

这段话的意思是 pub_date 字段没有默认值,而且非Null 那么 

1) 指定一个一次性的值供更改数据库时使用。

2) 停止当前操作,在 models.py 中给定默认值,然后再来migrate。

我们选择第一个,输入 1

Please enter the default value now, as valid Python

You can accept the default 'timezone.now' by pressing 'Enter' or you can provide another value.

The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now

Type 'exit' to exit this prompt

[default: timezone.now] >>> timezone.now()

Migrations for 'video':

  video\migrations\0005_video_create_time.py

    - Add field create_time to video

这样是生成了一个对表进行更改的 py 文件在 news/migrations 文件夹中,我们要执行更改

1python manage.py migrate 或 python manage.py migrate news

(video2) D:\2019\video2>python manage.py migrate

Operations to perform:

  Apply all migrations: admin, auth, comment, contenttypes, sessions, thumbnail, users, video

Running migrations:

  Applying video.0005_video_create_time... OK

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,419评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,793评论 0 23
  • 2 雨后的月季,花瓣上带着晶亮的水珠,浓的花香如此芬芳,美妙的无法形容。红的花瓣颜色过深,远看就像一种幽然的暗红,...
    尤其拉阅读 585评论 2 11
  • 我是日记星球239号星宝宝,来自深圳的叶子。我相信日积月累的力量,积跬步以致千里!这是第165篇日记。 大妮昨晚饭...
    水晶妈咪阅读 265评论 0 0
  • 不知道大家有没有过这样的经历。就是刚出生几个月的孩子如果别人抱在手上哭闹得很凶,但是到妈妈怀里,就会哭的没那么厉害...
    艾米本人阅读 2,592评论 0 0