﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35355	Images derived from models are not showing in template	Blauwe Stad Technologieen	nobody	"Images are not showing in templates despite following the documentation to the letter, which leave the conclusion that there is a bug with Django. I have the following:  

The directory goes as follows:  root  > media > assets

{{{

#models.py
class NewsArticle(models.Model):

    uuid            =   models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    image           =   models.ImageField(upload_to='assets/')

   
}}}



{{{
# settings.py
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_DIR = BASE_DIR / 'media'
}}}


{{{
#views.py
from django.urls import path, include
from . import views
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.views.static import serve


urlpatterns = [
    path('<uuid:uuid>', views.details),
    path('',views.article_list),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
}}}


{{{
# template
<img src=""{{article.image.url}}"" alt=""MyImage"">
}}}

Despite this, there is a bug with Django which prevents images from being shown in the template.
"	Bug	closed	Template system	4.2	Normal	invalid	models, ImageField		Unreviewed	0	0	0	0	0	0
