0

当我在本地机器上运行python manage.py collectstatic --noinput时,它工作正常。但是当 heroku 运行python manage.py collectstatic --noinput它会给出如下错误:for entry in os.scandir(path) FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_5d05d870/static'

我的项目目录如下所示:

mysite-----|libooki(app)----------|migrations
           |----------------------|init.py
           |----------------------|admin.py
           |----------------------|........
-----------|media
-----------|media_cdn
-----------|mysite
-----------|static|--------------|css|------style.css
-----------|staticfiles
-----------|templates
-----------|.........

我的settings.py看起来像这样。(我关注了这篇文章:https ://devcenter.heroku.com/articles/django-assets )

from pathlib import Path
import os
import django_heroku



BASE_DIR = Path(__file__).resolve().parent.parent
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')

INSTALLED_APPS = [
    ........,
    'libooki',
]

MIDDLEWARE = [
    ...........................................,
    'whitenoise.middleware.WhiteNoiseMiddleware',
]

WSGI_APPLICATION = 'mysite.wsgi.application'

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
MEDIA_ROOT = os.path.join(BASE_DIR,'media_cdn')
MEDIA_URL = '/media/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
django_heroku.settings(locals())
4

0 回答 0