静态文件昨晚正常运行。我今天什么时候做都没做,那么css文件将不再加载。
我在base.html上有{%load static%} 当我运行manage.py collectstatic时,这是错误消息:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 188, in handle
collected = self.collect()
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 105, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/contrib/staticfiles/finders.py", line 131, in list
for path in utils.get_files(storage, ignore_patterns):
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/contrib/staticfiles/utils.py", line 23, in get_files
directories, files = storage.listdir(location)
File "/Users/dir/portfolio/folio_env/lib/python3.7/site-packages/django/core/files/storage.py", line 315, in listdir
for entry in os.scandir(path):
FileNotFoundError: [Errno 2] No such file or directory: '/Users/dir/portfolio/portfolio/app/static'
答案 0 :(得分:0)
尝试从文件路径中删除app/
位。从项目层次结构来看,应该改为portfolio/portfolio/static
。