Answer the question
In order to leave comments, you need to log in
How to display an ImageField in a view?
Can't find an error. Images not showing, not found
settings.py
DEBUG = True
...
MEDIA_ROOT = os.path.join(BASE_DIR, 'articles')
MEDIA_URL = '/media/'
class Tutorials(models.Model):
image = models.ImageField(verbose_name='Лого статьи', upload_to='articles/')
{% for article in articles %}
<div class="row">
<img src="{{ article.image.url}}" >
</div>
{% endfor %}
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