媒体文件未显示在Debug False上 [英] Media files not showing on Debug False
本文介绍了媒体文件未显示在Debug False上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚使用pythonanywhere部署了一个站点,当我将 DEBUG
模式设置为 False
时,我的媒体映像消失了,找不到我的媒体文件夹的路径.我问自己是什么原因导致这个问题的,我该如何解决?
I've just deployed a site with pythonanywhere, when I set to DEBUG
mode to False
, my media images dissapear, the path of my media folder is not found. I was asking myself what causes this issue and how I can resolve it ?
这是我配置设置的方式:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
urls.py
urlpatterns = [
...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
推荐答案
使用 pythonanywhere 找到了它,我必须像这样在静态文件处理程序上设置媒体:
Found it, with pythonanywhere I had to setup media on the static files handler like this :
路径: /media/
目录: /home/< myusername>/< myproject>/media
然后将 DEBUG
设置为 False
后重新加载域名.
Then reload the domain name after setting DEBUG
to False
.
这篇关于媒体文件未显示在Debug False上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文