How to show an image of my model in the template?

0

That is the result of the template:

{% for eventos in eventos %}
    <h2>{{ eventos.nombre }}</h2>
    <p>{{ eventos.imagen }}</p>
    <p><b>Descripción:</b> {{ eventos.descripcion }}</p>
    <p><b>Fecha:</b> {{ eventos.fecha }}</p>
    <p><b>Hora:</b> {{ eventos.hora }}</p>
    <p><b>Lugar:</b> {{ eventos.lugar }}</p>
    <p><b>Ciudad:</b> {{ eventos.ciudad }}</p>
{% endfor %}

I need the image to show, I'm using django 1.10

    
asked by Ferney Bermeo Ruiz 31.01.2017 в 22:12
source

1 answer

0

If you declared the field in the model as ImageField, you just have to call it in the template in the following way:

{% for eventos in eventos %}
    <h2>{{ eventos.nombre }}</h2>
    <p><img src="{{ eventos.imagen }}"></p>
    <p><b>Descripción:</b> {{ eventos.descripcion }}</p>
    <p><b>Fecha:</b> {{ eventos.fecha }}</p>
    <p><b>Hora:</b> {{ eventos.hora }}</p>
    <p><b>Lugar:</b> {{ eventos.lugar }}</p>
    <p><b>Ciudad:</b> {{ eventos.ciudad }}</p>
{% endfor %}
    
answered by 02.02.2017 в 22:41