0

I'm trying to make a template dynamic. I added the jinja pattern wherever required and it worked except for the background images of the page.

I tried this:

    <div class="background_image" style="background-image:url({% static 'images/travello.jpg' %})"></div>

I expected to see the bg_image on the page, but i get nothing except blank white space. I get other images in the same folder using:

    <img src="{% static 'images/destination_4.jpg' %}" alt="">
3
  • missing the code you tried Commented May 27, 2019 at 12:06
  • 2
    use the inspector of your browser and see what is rendered Commented May 27, 2019 at 12:27
  • you need to enclose the url in single quotes to obtain url('/static/path/to/images/im.jpg'). If you look at the source code in your browser inspector you'll see the quotes are missing. Commented May 27, 2019 at 14:39

1 Answer 1

1

Just add static in front of the image url such as the following

<div class="background_image" style="background-image:url(static/images/travello.jpg)"></div>
Sign up to request clarification or add additional context in comments.

Comments

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.