Django shows 404 error on media files when debug =

2019-08-28 23:58发布

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 enter image description here

urls.py enter image description here

console errors enter image description here

1条回答
\"骚年 ilove
2楼-- · 2019-08-29 00:37

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.

查看更多
登录 后发表回答