我已经找到了类似的问题,但它们是几年前的,到目前为止,解决方案还没有奏效。
这是回溯:
(devtm) λ heroku run python manage.py collectstatic
Running python manage.py collectstatic on ⬢ {appname}... up, run.1335 (Free)
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, 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 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 199, in handle
collected = self.collect()
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 115, 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 112, 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 28, in get_files
directories, files = storage.listdir(location)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 397, in listdir
for entry in os.listdir(path):
OSError: [Errno 2] No such file or directory: '/app/{appname+"site"}/assets'
这是我的设置。py:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, '../{appname+"site"}/assets'),
os.path.join(BASE_DIR, '../{appname+"site"}/assets/css'),
os.path.join(BASE_DIR, '../{appname+"site"}/assets/images'),
os.path.join(BASE_DIR, '../{appname+"site"}/assets/js'),
os.path.join(BASE_DIR, '../{appname+"site"}/assets/venue_images')
)
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
我尝试将名为staticfiles
的目录(带有git的空白文件)添加到我的根目录(因此位于manage.py
文件旁边)。我尝试在具有assets
文件的文件夹中添加名为settings.py
的文件夹/文件,该文件似乎是回溯指示错误的地方。我还尝试了没有..
部分和没有../{appname}+"site"
部分的路径。
这是我第一次在Heroku上启动Django网站的尝试,而我为此付出了一个多星期的努力。我已经阅读了大量的文档和SO帖子,但是还无法查明问题所在。
答案 0 :(得分:0)
您的字符串未基于输出进行操作。他们被引用。 尝试更改适用的地方,例如: 注意: 我不知道什么是appname,如果它是变量或文字。
尝试更改以下声明以及其他类似的内容 os.path.join(BASE_DIR,'../{appname+"site"}/assets/css') 至: os.path.join(BASE_DIR,'../{appname'+'site'+'} / assets / css');