django - Django manage.py --no-input。是还是不是?

标签 django django-manage.py

我在文档中找不到这个。当我运行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_signalpost_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/

相关文章:

python - manage.py 标志强制执行无人值守命令?

django - 预构建的 Django 项目在迁移时出错

python - 在Dockerfile中运行 “manage.py compilemessages”可得到 “django.db.utils.OperationalError: could not connect to server: No such file or directory”

python - 从 django-admin 命令发送 django 信号?

python - 将 CSV 导入 MySQL 数据库 (Django Webapp)

python - 在views.py中自定义保存方法

django - 关于从 wordpress 迁移到 django 的建议、想法、提示和技巧或要点

javascript - Django Forms - 构建一个表单,显示来自多个不同模型的字段,但按外键排序

python - 切诺基导致产生多个 uwsgi 实例的问题