我正在使用 Django3,目前我的 makefile 中有以下用于“构建”的命令
python3 manage.py collectstatic
为了使用管道自动化我的构建过程,我想摆脱询问的提示
You have requested to collect static files at the destination location as specified in your settings:
URL
This will overwrite existing files! Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel
我发现我可以在最后为 collectstatic 添加“--no-input”,但在这种情况下这将回答“否”。 有没有办法让脚本默认回答"is"?
最佳答案
如 Django 文档中所述:
在随后的 collectstatic 运行中(如果 STATIC_ROOT 不为空),仅当文件的修改时间戳大于 STATIC_ROOT 中文件的时间戳时,才会复制文件。
所以默认情况下,django 会在 collectstatic 命令上覆盖您修改过的文件,--noinput 标志意味着它不会请求您的许可。
关于python - Django collectstatic --no input Yes 而不是 no,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66679629/