dennisklad
dennisklad

Reputation: 127

Django - Variable inside style not detected

{% if photos %}

     {% for photo in photos %}

     {% endfor %}

{% else %}

  No images availble for the project.

{% endif %}

And I want to add a picture url inside the style tag.

div class='image-block col-sm-4' style="background: url({{photo}}) no-repeat center top;background-   size:cover;"

How can I get the {{photo}} url inside the string?

Upvotes: 0

Views: 76

Answers (1)

Biplove Lamichhane
Biplove Lamichhane

Reputation: 4095

Simply try:

<div class='image-block col-sm-4' style="background: url("{{photo}}") no-repeat center top;background-size:cover;"></div>

Upvotes: 1

Related Questions