简体   繁体   中英

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. 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 在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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