How to display images from model in Django?

后端 未结 1 1013
天涯浪人
天涯浪人 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 %}
    <img src="{{ n.nazwa.url }}" />
    {% endfor %}
    

    Hope this helps.

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