[英]Django shows 404 error on media files when debug = False in production
I'm trying to put a django website live and after going through the deployment checklist and turning debug = False
django gives out a 404 error and only static files are loaded no media files uploaded from users are displayed. 我正在尝试打开django网站,并通过了部署清单并打开了
debug = False
django发出404错误,并且仅加载了静态文件,没有显示从用户上传的媒体文件。 However with debug=True
all the images and files work properly. 但是,通过
debug=True
所有图像和文件都可以正常工作。 below are the configurations of the project with debug = True
. 以下是
debug = True
的项目配置。 The console logs show multiple missing files.can someone point to me what i'm doing wrong? 控制台日志显示多个丢失的文件。有人可以指出我在做什么错吗?
Basically you are putting the application in DEBUG=False
"mode", this means that django won't serve any static files. 基本上,您将应用程序置于
DEBUG=False
“模式”下,这意味着django将不会提供任何静态文件。 But on the other hand, if you want to test locally how DEBUG=False
affects your environment, locally you can use python manage.py runserver --insecure
option which will allow django to serve static files. 但另一方面,如果要在本地测试
DEBUG=False
如何影响环境,则可以在本地使用python manage.py runserver --insecure
选项,该选项将允许django提供静态文件。 But I must note that this is vastly inefficient and maybe insecure too. 但是我必须指出,这是非常低效的,也许也不安全。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.