0

ファイルの集約/生成を行っており、その後すぐに collectstatic を実行したいと考えています。理想的には、collectstatic コマンドを拡張するか (これが可能かどうかはわかりません)、制御をそのコマンドにチェーンします。私は2番目を試しましたが、うまくいきません:

class Command(BaseCommand):
    can_import_settings = True

    def handle(self, *args, **options):
        something_necessary()
        execute_from_command_line('collectstatic')

このジャンゴの初心者からの前もって感謝します。

コマンドラインから実行する編集は興味深い

C:\www\app>python manage.py customCmd
ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

わかりました - 私のコマンドは MySQLdb を使用しないので、これは興味深いことです。しかし、collectstatic を個別に試してみると、次のように動作します。

C:\www\app>python manage.py collectstatic
C:\Python33\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py:65: DeprecationWarning: stat_float_times() is deprecated
  os.stat_float_times(False)


You have requested to collect static files at the destination
location as specified in your settings.

This will overwrite existing files!
Are you sure you want to do this?

コマンドを次のように簡単に書くと

from django.core.management.base import BaseCommand

class Command(BaseCommand):
    can_import_settings = False

    def handle(self, *args, **options):
        pass

コマンド ラインを実行すると、MySQLdb エラーが発生します。

だから私が知っていること

  1. execute_from_command_line を呼び出さない場合は、PyCHarm IF から正常に動作します
  2. カスタム コマンドをコマンド ラインから実行できません (python manage,py customCmd)
  3. collectstatic は、PyCHarm インターフェースとコマンドラインの両方から正常に動作します
4

0 に答える 0