我正试图在Heroku上部署我的Django webapp应用程序。每次尝试部署时,我都会面临同样的错误。
ImportError:您的WhiteNoise配置与WhiteNoise v4.0不兼容--这可以通过在:http://whitenoise.evans.io/en/stable/changelog.html#v4-0上执行升级说明来修复!运行“$ python manage.py收集器-noinput”时出错。有关详细信息,请参阅上面的回溯。您可能需要更新应用程序代码以解决此错误。或者,您可以禁用此应用程序的收集器:$ heroku config:set DISABLE_COLLECTSTATIC=1 https://devcenter.heroku.com/articles/django-assets!拒绝推,编译Python应用程序失败。好了!推送失败
如文档所示,我访问了该链接以进行更改。它要求我删除wsgi.py文件中提到的任何内容,并且必须将其添加到settings.py中的中间件中,并更改静态存储。
#settings.py
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
.
.
.
.
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'我不知道是什么导致了这个错误。应用Whitenoise更新,静态文件也就位。
这个项目在本地服务器上很有魅力,但我只是无法部署它。提前感谢!
发布于 2019-06-14 10:44:18
whitenoise.django.GzipManifestStaticFilesStorage化名现在已被移除。相反,您应该使用正确的导入路径:
whitenoise.storage.CompressedManifestStaticFilesStorage源链接
发布于 2020-07-07 18:17:26
在wsgi.py中使用
from whitenoise import WhiteNoise
而不是
from whitenoise.django import DjangoWhiteNoise
发布于 2020-07-21 03:52:16
我基本上遵循了这个页面上的指示到把它修好。
Django的WSGI集成选项(涉及编辑wsgi.py)已经被删除。相反,您应该将WhiteNoise添加到settings.py中的中间件列表中,并从wsgi.py中删除对WhiteNoise的任何引用。
https://stackoverflow.com/questions/55813584
复制相似问题