Tuesday, May 28, 2019

Re: Display image in template

You will have to setup MEDIA path f8rst. All your uploded files will be stored in that folder. STATIC path is used only for, well, static content like css and js.

On Tue, 28 May 2019, 23:31 anchal agarwal, <agarwalanchal72@gmail.com> wrote:
I want to display image dynamically from the database in a django template. I have used ImageField for this purpose. The code shows no error but it is only displaying an icon of image.
This is my template file,
here album is the context and album_logo is the variable in which i have stored my image. please tell me how can i fix this issue
<img src="{{ album.album_logo}}">

<h1>{{ album.album_title}}</h1>
<h3>{{ album.artist }}</h3>

<ul>
{% for song in album.song_set.all %}
<li>{{song.song_title}}-{{song.file_type}}</li>
{% endfor %}
</ul>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMT%3DisWxuO9d1tTMacyYauDAmQS%2B2e_B9HawfZP7eY8smCS%3D2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAC3mK7fGps2XR1S7V%2B4WvU-%2Boma-eoUTrtDjEwVJe2QtCTL_Xg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment