2017-01-30 6 views
4

ドキュメントでこれを見つけることができません。 python manage.py collecstatic --no-inputを実行すると、プロセスでポップアップするすべてのプロンプトに対して「はい」と答えますか? python manage.py migrate --no-inputでも同じです。Django manage.py --no-input。はい、もしくは、いいえ?

+1

を意味し、コンテンツタイプ。 https://code.djangoproject.com/ticket/25036 – wim

答えて

8

いつでもちょうど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.") 

そこらコレクト静的、あなたはそれがFalseinteractiveを設定しますと、あなたは上記を参照できるように、あなたのための質問にyesにお答えします--no-inputを設定している場合。

移行のためには、djangoシグナリングのために非常にトリッキーです。 migrate管理者自身は質問をしませんが、インストールされている他のアプリはpre_migrate_signalまたはpost_migrate_signalに接続し、独自のやり方で対話性を処理できます。私の知っている最も一般的なものはcontenttypesについてはcontenttypes

で、interactiveは、私は一般的に、それは `yes`に答えることだが、私はそれが古い削除に失敗して、バグの前に気づいたと思う号

 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 
+0

ありがとうございました。これはドキュメント内にある必要があります。 – alejoss

関連する問題