【发布时间】:2021-02-09 11:27:00
【问题描述】:
这是部署在 heroku 中的管理页面, enter image description here 这是我的设置。py
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
deploy_settings.init.py
DEBUG = False
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
我尝试在本地运行 python manage.py collectstatic,并在 heroku bash 中也运行它,但它不起作用。我们真的需要运行这个命令吗?还是在推送到heroku master 时收集静态文件? 我试图在 heroku 配置变量中添加 DEBUG_COLLECTSTATIC=1 ,但它不起作用。 最后一点,我尝试安装 whitenoise 并将其添加到 settings.py 中间战争,然后添加 STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' in deply_settings.init.py 但我收到此错误, enter image description here 当
【问题讨论】:
-
一个简单的谷歌搜索出现了这个:devcenter.heroku.com/articles/django-assets - 你试过了吗?