background-image: url( with a URL that has parentheses with Django template

Asked

Viewed 127 times

0

I have a div as follows:

<div style='background-image: url({{ OBJETO.URL }})' class="video-thumb"></div>

Where Objeto.url deliver a string like this:

http://dominio/rota/id/original/(nome)8.jpg

When it renders the HTML it is invalid in that background-image because the second parentheses of that piece (nome) closes the value of the backgroud-image url.

Through the browser, inspecting and placing double quotes around it works.

So I tried to change the html to:

<div style='background-image: url("{{ OBJETO.URL }}")' class="video-thumb"></div>

But he ignored the quotes at that point.

I’d like to know how to make him consider (nome) as part of my URL.

1 answer

4


Escape the parentheses by using %28 (() and %29 ()).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.