[Fixed]-The image in Django app not working

1👍

For example you need to create the list of objects of Album model:

def listAlbum(request):
  album_list = Album.objects.all()
  return render(request, '/your/template.html', {'album_list':album_list})

in this case to show the image of objects in template it should look like this:

{% for a in album_list %}
   <img src="{{a.album_logo}}>
{% endfor %}

If you want to display detail object, then your view should look like this:

def detailAlbum(request, pk):
  album = Album.objects.get(pk=pk)
  return render(request, '/your/template.html', {'album':album})

In this case your template should looks like this:

<img src="{{a.album}}>

Hope it helps you

Leave a comment