私はdjangoフレームワークでWebを開発しています。Django - 静的ファイルを読み込めません(404エラー)
私はこのような静的ファイルに3つのフォルダを持っています。
*web
*home
*static
*admin
*scripts
*styles
*web
*manage.py
*db.sqlite3
と私はsuccessfuly静的なファイルを収集することができます私はこの静的な設定で自分の設定ファイル
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)
を持っている。しかし、私はmanage.py collectstaitcをのpython3入力したとき、私はこの結果
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/pwanhsu/django/django/core/management/__init__.py", line 349, in execute_from_command_line
utility.execute()
File "/Users/pwanhsu/django/django/core/management/__init__.py", line 341, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/pwanhsu/django/django/core/management/base.py", line 290, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/pwanhsu/django/django/core/management/base.py", line 341, in execute
output = self.handle(*args, **options)
File "/Users/pwanhsu/django/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
collected = self.collect()
File "/Users/pwanhsu/django/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/Users/pwanhsu/django/django/contrib/staticfiles/finders.py", line 112, in list
for path in utils.get_files(storage, ignore_patterns):
File "/Users/pwanhsu/django/django/contrib/staticfiles/utils.py", line 28, in get_files
directories, files = storage.listdir(location)
File "/Users/pwanhsu/django/django/core/files/storage.py", line 286, in listdir
for entry in os.listdir(path):
FileNotFoundError: [Errno 2] No such file or directory: '/Users/pwanhsu/Desktop/v_bridge/web/web/static'
を取得このようなSTATICFILES_DIRSを削除すると、
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
0 static files copied to '/Users/pwanhsu/Desktop/v_bridge/web/static', 56 unmodified.
012私のHTMLファイルに
、私が持っているこれらのコード
{%負荷staticfiles%}
しかし、サーバーは私に
[08/Sep/2016 03:36:45] "GET/HTTP/1.1" 200 5831
[08/Sep/2016 03:36:45] "GET /static/scripts/bootstrap/css/bootstrap-responsive.min.css HTTP/1.1" 404 1763
[08/Sep/2016 03:36:45] "GET /static/scripts/icons/social/stylesheets/social_foundicons.css HTTP/1.1" 404 1775
[08/Sep/2016 03:36:45] "GET /static/scripts/icons/general/stylesheets/general_foundicons.css HTTP/1.1" 404 1781
誰もがどのようにについての考えを持っている404エラーを返します静的なパスを設定するか、私が間違っていたものを設定してください。本当にそれと混同します。
サーバーは私にこれを返します "STATICFILES_DIRS設定はSTATIC_ROOT設定を含むべきではありません" – Pwan