Display images in Django

前端 未结 5 906
遇见更好的自我
遇见更好的自我 2020-12-11 05:53

I have a django app which allows users to submit an image with it. Right now my model looks like

class Posting(models.Model):
    title = models.CharField(m         


        
5条回答
  •  孤街浪徒
    2020-12-11 06:16

    Do something like this. This code is working in my app.

    views.py:

    def list(request):
      images = Image.objects.all()
      return render(request, "list.html", {'images': images})
    

    list.html:

    {% for i in images %}
        
    {% endfor %}
    

提交回复
热议问题