【问题标题】:Django admin template css is not loaded when deploy it in Heroku?在 Heroku 中部署 Django 管理模板 css 时未加载?
【发布时间】: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

【问题讨论】:

标签: python django heroku


【解决方案1】:

已通过删除 deploy_settings.init.py 中的这一行来修复

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-22
    • 2019-08-21
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    • 1970-01-01
    • 2012-09-13
    相关资源
    最近更新 更多