Python “Heroku django”;OSError:[Errno 2]没有这样的文件或目录:'/静态/静态'&引用;
我是django和heroku的新手。这就是我在将git存储库部署到heroku时遇到的错误。请建议我需要更改的更改。先谢谢你 (网站)C:\Users\website\src>heroku运行python manage.py --无输入 正在运行附加到终端的Python “Heroku django”;OSError:[Errno 2]没有这样的文件或目录:'/静态/静态'&引用;,python,django,git,heroku,Python,Django,Git,Heroku,我是django和heroku的新手。这就是我在将git存储库部署到heroku时遇到的错误。请建议我需要更改的更改。先谢谢你 (网站)C:\Users\website\src>heroku运行python manage.py --无输入 正在运行附加到终端的python manage.py collectstatic--noinput。。。起来,跑 Traceback (most recent call last): File "manage.py", line 10, in <
python manage.py collectstatic--noinput
。。。起来,跑
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__
.py", line 385, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__
.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py"
, line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py"
, line 338, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py"
, line 533, in handle
return self.handle_noargs(**options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle_noargs
collected = self.collect()
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 111, in list
for path in utils.get_files(storage, ignore_patterns):
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 27, in get_files
directories, files = storage.listdir(location)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py",
line 270, in listdir
for entry in os.listdir(path):
OSError: [Errno 2] No such file or directory: '/static/static'
目前,错误似乎来自STATICFILES_DIRS var指向不存在的目录:
STATICFILES_DIRS = (os.path.join(os.path.dirname(BASE_DIR), "static", "static" )
转到Django项目目录,找到静态存储库,并记下绝对位置。
然后,编辑settings.py中的STATICFILES_DIRS变量,使其指向此位置
对我来说(这并不意味着对你来说应该是一样的),它看起来是这样的:
STATICFILES_DIRS = (os.path.join(BASE_DIR, '../myapp/static'),)
如果您已按如下方式声明了“STATICFILES\u DIRS”变量
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
确保:
您应该发布settings.py中有关STATIC\u ROOT、STATIC\u URL或STATICFILES\u direrror的部分。错误更改为:
OSError:[Errno 2]没有这样的文件或目录:'/myapp/STATIC'
这是我试图将git推送到heroku准备静态资产时出现的错误静态配置错误。要调试,请运行:$heroku run python./manage.py collectstatic--noinput
但我没有告诉您要编写“myapp/static”,这只是我所做工作的一个示例,但我想您的应用程序不是“myapp”!!!你必须找到要写的内容,找到正确的位置。我的应用程序名为“myapp”
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]