Django media files not showing with Debug = False on production - Django 1.10

You shouldn't use collectstatic for your media directory. Remove '/home/admin/webapps/mainfolder/mainapp/media' from STATICFILES_DIRS, then set

MEDIA_ROOT = '/home/admin/webapps/mainfolder/mainapp/media'

Once you've done this, the static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) should serve media files when DEBUG = True.

For DEBUG = False, you have to configure Apache to serve the media files.


If you are using Nginx, let it to serve media files

For Example

go to nginx/sites-available & add this

location /media/ { root */home/myprojectdir/myproject*; } 

In your urls.py file:

add this line

from django.views.static import serve

add those two urls in urlpatterns:

url(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),
url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),

It worked for me :)