我在文档中找不到这个。当我运行python manage.py collecstatic --no-input
时,是否表示会对过程中 pop 的任何提示回答"is"? python manage.py migrate --no-input
也一样。
最佳答案
对于静电收集器:
message.append(
'Are you sure you want to do this?\n\n'
"Type 'yes' to continue, or 'no' to cancel: "
)
if self.interactive and input(''.join(message)) != 'yes':
raise CommandError("Collecting static files cancelled.")
因此,对于静态收集而言,如果您设置
--no-input
,它将interactive
设置为False
,并且如上所示,将为您回答问题的yes
。对于迁移来说,由于django信令,这要复杂得多。
migrate
管理本身不会提出任何问题,但是其他已安装的应用程序可能会挂接到pre_migrate_signal
或post_migrate_signal
中,并以自己的方式处理交互性。我知道的最常见的是contenttypes
对于
contenttypes
,--no-input
回答“否”,如“否,请不要删除任何过时的内容类型”: if interactive:
content_type_display = '\n'.join(
' %s | %s' % (ct.app_label, ct.model)
for ct in to_remove
)
ok_to_delete = input("""The following content types are stale and need to be deleted:
%s
Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.
Type 'yes' to continue, or 'no' to cancel: """ % content_type_display)
else:
ok_to_delete = False
关于django - Django manage.py --no-input。是还是不是?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41943205/