简体   繁体   English

Django项目在heroku中不显示图像

[英]Django project does not display images in heroku

When I upload the project to heroku, and change DEBUG=True to DEBUG=False, the images stop showing当我将项目上传到 heroku 并将 DEBUG=True 更改为 DEBUG=False 时,图像停止显示

That's my static and media root那是我的静态和媒体根

STATIC_ROOT = Path(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

MEDIA_ROOT = Path(BASE_DIR, 'media')
MEDIA_URL = '/media/'

Essentially, by changing debug to false, you've put django into 'production' mode, which changes what is necessary for static files to be found.本质上,通过将 debug 更改为 false,您已将 django 置于“生产”模式,这改变了找到静态文件所必需的内容。 This is done because the 'dev' method is not proven secure.这样做是因为“开发”方法未被证明是安全的。

For what to do in horoku, the horoku documentation has you covered:对于 horoku 中的操作, horoku 文档为您提供:

For more information, the django docs talk about the process as well有关更多信息, django 文档也讨论了该过程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM