How to display images from model in Django?

后端 未结 1 1014
天涯浪人
天涯浪人 2020-12-18 08:00

How to display images from model in templates?

I will display images from photos directory (upload_to=\'photos\') in my template index.html. How to do?

For e

1条回答
  •  轮回少年
    2020-12-18 08:23

    Everything you need is well documented here and here. Youll need to pass your img into the template and use its url() method.

    In your template you can do something like this:

    {% for n in img %}
    
    {% endfor %}
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题