在过去的几个小时里,我一直在通过 Stack Overflow 搜索修复,但大多数关于服务器错误 500 的帖子都无法为我提供修复。Django 找不到静态图片并返回 500。图片在 static/css/images 中。
例如,我尝试获取https://monkeyparliament.herokuapp.com/about/。日志返回:
2019-02-10T17:09:33.362724+00:00 app[web.1]: ValueError: Missing staticfiles manifest entry for 'css\images\donate.png'
2019-02-10T17:09:33.363611+00:00 app[web.1]: 10.31.121.50 - - [10/Feb/2019:17:09:33 +0000] "GET /about/ HTTP/1.1" 500 27 "https://monkeyparliament.herokuapp.com/music/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36"
但是当我https://monkeyparliament.herokuapp.com/music/时,它似乎可以在静态文件夹中找到 css/js/fonts 。随意检查页面源。
我的静态图像由 WhiteNoise ( http://whitenoise.evans.io/en/stable/ ) 提供。正如您在上面看到的,WhiteNoise 在要求中。settings.py 中的 MIDDLEWARE 在 django.middleware.security.SecurityMiddleware 下方添加了“whitenoise.middleware.WhiteNoiseMiddleware”。
为什么找不到我的图片?
档案
web: gunicorn websitemp.wsgi:application --log-file -
要求.txt
dj-database-url==0.5.0
Django==2.0.10
gunicorn==19.9.0
psycopg2==2.7.7
pytz==2018.9
whitenoise==4.1.2
结构
website是应用程序,websitemp是项目
Github 上的项目
如果您想查看完整结构,您可以在 github 上找到所有文件:https ://github.com/DennisVerstappen/websitempdjango
提前致谢!