I learn Django and I have a problem with display img in settings I add:
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "moje_media")
and in url.py I add static
urlpatterns = [
//routing
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Problem is that img is uploading correctly but I have a problem with display that. For example - in my template I have img tag:
<img src="{{MEDIA_URL}}{{film.plakat}}">
But it doesn't display that. I inspect img that and src contain "/media/plakaty/test.jpg". I go to
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
admin/
filmy/
login/ [name='login']
logout/ [name='logout']
^media/(?P<path>.*)$
The current path, media/plakaty/test.jpg, matched the last one.
What is wrong?