私のWebサーバーを使って静的なファイルを提供したいと思います。DjangoのcollectstaticがSTATIC_ROOTのadmin/__ init__.pyにアクセスしようとしていません
現在インストールされている唯一のアプリケーションはdjango.contrib.admin
です。これには静的ファイルが含まれています。
すべては、./manage.py runserver
でうまく動作します。静的ファイルは適切に配信されます。
しかし、./manage.py collectstatic
を実行できません。
これは私がdjango.contrib.staticfiles
を設定した方法です:
- 私が書き込み可能な、空のディレクトリに
STATIC_ROOT
を設定しました。 :私は自分のアプリケーションフォルダ内collectstatic
を実行しようとする今、私は非常に奇妙なエラーメッセージが表示されますSTATIC_URL = '/static/' STATICFILES_DIRS =() STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )
:私はそのデフォルト値に他のすべてを残してきた
/var/www/SITE_NAME/static/
それを呼び出すことができます
$ ./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
がSTATIC_ROOT
にありますか?このディレクトリに静的ファイルをコピーするだけの理由は何ですか?
これは、私が見ていなかった 'STATIC_ROOT'ディレクトリの不正なアクセス権のためです! 私はなぜこのような誤解を招くエラーメッセージがなぜ、なぜ 'collectstatic'が' __init __。py'と '__init __。pyc'ファイルもコピーするのか理解できません。 これらのファイルもなぜコピーされていますか?彼らは静的なファイルではありません! – alexpirine