Web サーバーを使用して静的ファイルを提供したいと考えています。
現在インストールされているアプリケーションは 1 つだけで、django.contrib.admin
提供したい静的ファイルがいくつか含まれています。
すべてが正常に動作し./manage.py runserver
ます。静的ファイルは適切に提供されます。
しかし、私は走ることができません./manage.py collectstatic
。
これは私が設定した方法ですdjango.contrib.staticfiles
:
STATIC_ROOT
書き込み可能な空のディレクトリに設定しました。呼びましょう/var/www/SITE_NAME/static/
他のすべてをデフォルト値のままにしました:
STATIC_URL = '/static/' STATICFILES_DIRS = () STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )
collectstatic
アプリケーションフォルダー内で実行しようとすると、非常に奇妙なエラーメッセージが表示されます。$ ./manage.py collectstatic You have requested to collect static files at the destination location as specified in your settings file. This will overwrite existing files. Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: yes Copying '/usr/lib/pymodules/python2.7/django/contrib/admin/media/__init__.py' Traceback (most recent call last): File "./manage.py", line 14, in <module> execute_manager(settings) File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/usr/lib/pymodules/python2.7/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/pymodules/python2.7/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/lib/pymodules/python2.7/django/core/management/base.py", line 220, in execute output = self.handle(*args, **options) File "/usr/lib/pymodules/python2.7/django/core/management/base.py", line 351, in handle return self.handle_noargs(**options) File "/usr/lib/pymodules/python2.7/django/contrib/staticfiles/management/commands/collectstatic.py", line 89, in handle_noargs self.copy_file(path, prefixed_path, storage, **options) File "/usr/lib/pymodules/python2.7/django/contrib/staticfiles/management/commands/collectstatic.py", line 199, in copy_file shutil.copy2(source_path, full_path) File "/usr/lib/python2.7/shutil.py", line 127, in copy2 copyfile(src, dst) File "/usr/lib/python2.7/shutil.py", line 82, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 2] No such file or directory: u'/var/www/SITE_NAME/static/admin/__init__.py'
このエラー メッセージが表示されるのはなぜですか?
意味がないようです。
このディレクトリに静的ファイルをコピーするだけなのに、なぜadmin/__init__.py
inを探すのでしょうか?STATIC_ROOT