Ale*_*lla 16 django django-manage.py
我在文档中找不到这个.当我运行时python manage.py collecstatic --no-input
它是否意味着它会对流程中弹出的任何提示回答"是"?同样的python manage.py migrate --no-input
.
2ps*_*2ps 32
您可以随时查看django源代码.你知道,它是开源的.
对于collectstatic:
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.")
Run Code Online (Sandbox Code Playgroud)
所以对于收集静态,如果你设置--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
Run Code Online (Sandbox Code Playgroud)