Django shows 404 error on media files when debug = False in production

狂风中的少年 提交于 2019-12-11 16:28:59

问题


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. However with debug=True all the images and files work properly. below are the configurations of the project with debug = True. The console logs show multiple missing files.can someone point to me what i'm doing wrong?

settings.py

urls.py

console errors


回答1:


Basically you are putting the application in DEBUG=False "mode", this means that django won't serve any static files. 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. But I must note that this is vastly inefficient and maybe insecure too.

Hope this helps.



来源:https://stackoverflow.com/questions/47948586/django-shows-404-error-on-media-files-when-debug-false-in-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!