[英]PythonAnywhere image not found
Before anyone deletes this due to the question being similar to others: Neither other questions nor the documentation got my site to work as intended.由于问题与其他问题相似,在任何人删除此内容之前:其他问题和文档都没有让我的网站按预期工作。
The goal: Load images on my site目标:在我的网站上加载图片
The problem: Image not found问题:找不到图片
Additional info: It works locally using python manage.py runserver
附加信息:它使用
python manage.py runserver
在本地工作
What I've done to try to fix it:我为尝试修复它所做的工作:
I've tried to follow the staticfiles guide https://help.pythonanywhere.com/pages/DjangoStaticFiles but this didn't work because I'm not using the default uploaded files handling.我尝试遵循静态文件指南https://help.pythonanywhere.com/pages/DjangoStaticFiles但这不起作用,因为我没有使用默认的上传文件处理。
I've tried to enter it under the PythonAnywhere > Web > static files tab but haven't been able to get that to work.我尝试在 PythonAnywhere > Web > static 文件选项卡下输入它,但无法让它工作。
Tried a bunch of different solutions from the PythonAnywhere forum and SO forum and none got my site to work.从 PythonAnywhere 论坛和 SO 论坛尝试了一堆不同的解决方案,但都没有让我的网站正常工作。
The site: http://nasablogdeployment.eu.pythonanywhere.com/站点: http://nasablogdeployment.eu.pythonanywhere.com/
All code available here: https://github.com/MarkdenToom/NASA-blog此处提供的所有代码: https://github.com/MarkdenToom/NASA-blog
Static files directories here: https://imgur.com/xL0RN8A Static 文件目录在这里: https://imgur.com/xL0RN8A
WSGI file content: https://imgur.com/dJY4knp WSGI文件内容: https://imgur.com/dJY4knp
Your web app is looking for the picture in http://nasablogdeployment.eu.pythonanywhere.com/blog/media/thumbnails/Touchdown_Expedition_62_Returns_to_Earth_Completes_Station_Mission.jpg
while your current mapping resolves into url like that: http://nasablogdeployment.eu.pythonanywhere.com/media/thumbnails/Touchdown_Expedition_62_Returns_to_Earth_Completes_Station_Mission.jpg
Your web app is looking for the picture in
http://nasablogdeployment.eu.pythonanywhere.com/blog/media/thumbnails/Touchdown_Expedition_62_Returns_to_Earth_Completes_Station_Mission.jpg
while your current mapping resolves into url like that: http://nasablogdeployment.eu.pythonanywhere.com/media/thumbnails/Touchdown_Expedition_62_Returns_to_Earth_Completes_Station_Mission.jpg
Change your static files mapping so the /blog/media/
points to /home/nasablogdeployment/NASA-blog/blog/media/
更改您的 static 文件映射,以便
/blog/media/
指向/home/nasablogdeployment/NASA-blog/blog/media/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.