How to display images in the template (Django)?

Problem when outputting an image to a template. There is a field of the model:
image = models.ImageField(upload_to="media/", verbose_name='Image', help_text='150x150px')

settings.py:
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = 'C:/code2015/pf/'

In the template like this:
<img src="{{MEDIA_URL}}{{ work.image }}" width="150" height="150" alt="Example">

When it formed this:
<img src="C:/code2015/pf/media/work2.jpg" width="150" height="150" alt="Example">

But in the blank squares:
Not allowed to load local resource: file:///C:/code2015/pf/media/work2.jpg


I file:///C:/code2015/pf/media/work2.jpg and displays the desired picture.

How to solve this problem?
Python 3.4, Django 1.7.3

Solution:
djbook.ru/rel1.7/howto/static-files/#serving-files...
from django.conf import settings
from django.conf.urls.static import static

mapping includes = patterns(",
 # ... the rest of your URLconf goes here ...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
September 19th 19 at 12:10
2 answers
September 19th 19 at 12:12
Solution
Yes, thank you, it worked. - Anne_Nol commented on September 19th 19 at 12:15
September 19th 19 at 12:14
MEDIA_URL = '/media/'
tried that, also did:
Failed to load resource: the server responded with a status of 404 (NOT FOUND)
img src="/media/media/work2.jpg" width="150" height="150" alt="Example" - Anne_Nol commented on September 19th 19 at 12:17
And if you just the browser open 127.0.0.1:8000/media/work2.jpgopens? - Anne_Nol commented on September 19th 19 at 12:20
: Doesn't open, Page not found (404) - Oran.Stiedeman commented on September 19th 19 at 12:23
Make sure that settings.py is
SERVE_STATIC=True
and
DEBUG=True - Anne_Nol commented on September 19th 19 at 12:26
DEBUG was standing, but SERVE_STATIC was not set and nothing has changed - Oran.Stiedeman commented on September 19th 19 at 12:29

Find more questions by tags Web DevelopmentPythonDjango