[Answer]-Django can't show images on page

1๐Ÿ‘

โœ…

^media/$ is a very wrong regex for media files. You should delete the $ (end-of-the-string) sign from this regex.

Usually for development environments I use this snippet in the urls.py:

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('',
    ...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Also remove the useless {{ MEDIA_ROOT }} part from your template code. It should be:

<img src="{{ image.picture.url }}" />
๐Ÿ‘คcatavaran

0๐Ÿ‘

In adition the line that you have to add is..

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('',
    ...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

But it has to be in the urls.py of your project folder. not in the urls.py of your App folder. I knew it by mistake.

๐Ÿ‘คheber camargo

Leave a comment