collectstatic上的Heroku / Django错误:OSError:[Errno 2]没有这样的文件或目录

时间:2018-08-09 22:04:39

标签: django heroku collectstatic

我开始担心我永远都不会启动我的网站。

我已经在heroku上启动了一个应用程序,但是如果没有出现OSError,我将无法运行heroku run python manage.py collectstatic

跟踪:

Running python manage.py collectstatic on ⬢ tallymusic... up, run.1934 (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/tallymusicsite/assets'

这是我的settings.py静态设置:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'tallymusic/assets'),
    os.path.join(BASE_DIR, 'tallymusic/assets/css'),
    os.path.join(BASE_DIR, 'tallymusic/assets/images'),
    os.path.join(BASE_DIR, 'tallymusic/assets/js'),
    os.path.join(BASE_DIR, 'tallymusic/assets/venue_images')
)

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

我非常有信心该错误来自我的STATICFILES_DIRS设置,但我无法弄清楚。我已经在StackOverflow上阅读了很多有关此错误的答案,并尝试了建议的每个排列,包括:

'../tallymusic/assets'
'../tallymusicsite/assets'
'app/tallymusic/assets'
'app/tallymusicsite/assets'
'tallymusic/tallymusicsite/assets'

等等。

我什至都不知道我应该使用什么项目名称。我的外部文件夹一直被称为tallymusic,但是保存settings.py文件的文件夹称为tallymusicsite。这是否使tallymusicsite成为项目名称?

很明显,我不了解一些基本知识。静态文件的Django文档也无济于事。我什至无法描述我对此会提供多少帮助。如果我应该提供更多信息,请告诉我。

编辑后添加:

这是我的文件结构:

tallymusic
-- manage.py
--> apps, etc.
...
--> assets # actually has the files
--> tallymusicsite
---- settings.py
----> assets # read on a SO post that this is where I want the folder?
...

让我知道您是否需要更多文件结构。

0 个答案:

没有答案