gpt4 book ai didi

Django: python manage.py migrate --noinput

转载 作者:行者123 更新时间:2023-12-05 01:16:57 24 4
gpt4 key购买 nike

我正在考虑将命令 release: python manage.py migrate --no-input 添加到我的部署中,因此一旦我推送我的存储库,Heroku 就会自动迁移。我现在想知道 --no-input 是不是一个“好”主意?

一个更具体的问题:如果迁移通常会问我“你重命名了这个字段吗”。使用--no-input,它会自动回答yes吗?我在官方 Django 文档中找不到太多详细信息。

最佳答案

我们在管道中不使用 interactive 标志 (--no-input),据我所知,这并没有太大区别。如果您检查 Django 源代码,您会发现交互标志只属于迁移前后发出的 pre_migratepost_migrate 信号。

据我所知,没有任何内部 Django 应用程序在这些信号中使用交互式参数。一些外部软件包也许可以使用它,但我个人从未遇到过。

至于你的问题:

One more specific question: If migrate normally asks me 'Did you rename this field'. With --no-input, will it answer automatically yes? I couldn't find much detailed information in the official Django documentation.

这发生在 makemigrations 管理命令中,而不是在 migrate 中。您通常在本地执行(并且应该执行)前者,因此无需将其包含在您的部署管道中。

关于Django: python manage.py migrate --noinput,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52140030/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com