1

I passed context_object_name = 'project' in template and I need this:

<div style="background-image: url( {{ project.thumbnail.url}}  )"></div>

but above line doesn't work. However, <img src="{{ project.thumbnail.url }}" alt="thumb" /> works fine.

What is the solution? Thank you in advance

1 Answer 1

2

It should work with the way you did, you are just missing the width and height attributes

this one works for me:

<div style="background-image: url( {{project.thumbnail.url}}  ); width:500px; height:500px;"></div>
Sign up to request clarification or add additional context in comments.

2 Comments

exactly, I defined those width and height in css. sounds like it has been overwritten. This one made it. Thanks
Glad that it helped. You can either do <div style="background: url({{project.thumbnail.url}}); background-repeat: no-repeat; background-size: 500px 500px"> fill it here <br> <br> it will display the background with content </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.