django 1.10 media images don't show

你离开我真会死。 提交于 2019-12-04 12:55:30

You can use this: (Django docs 1.10 Serving files uploaded by a user during development)

urlpatterns = [
   ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

OR you can use this (if you only want it in development with the Debug = True in you'r settings): Django docs 1.10 Serving files in development

if settings.DEBUG:
    urlpatterns += [
        url(r'^media/(?P<path>.*)$', serve, {
            'document_root': settings.MEDIA_ROOT,
        }),
    ]

For me the {{ MEDIA_URL }} didn't work anymore in my template file, I used the {% get_media_prefix %}:

Ex.:

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