Answer the question
In order to leave comments, you need to log in
Can't display Django image?
Good day, I can not display the images that are uploaded to the site through the model. I looked at related questions on the toaster, their solutions did not help either.
# Model
...
image = models.ImageField(upload_to='image/')
...
#Urls
urlpatterns = [
url(r'^portfolio/', include('portfolio.urls')),
url(r'^auth/', include('loginsys.urls')),
url(r'^admin/', admin.site.urls),
url(r'^', include('article.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# Setings
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
#Template
<li><img src="{{ item.image }}" alt="" /></li>
urlpatterns = [
url(r'^portfolio/', include('portfolio.urls')),
url(r'^auth/', include('loginsys.urls')),
url(r'^admin/', admin.site.urls),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += [url(r'^', include('article.urls'))]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question