0

My view send to my template one object with this value:

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

In my templete I have:

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

When my template is rendered it looks like this:

background-image: url(' http://dominio/rota/id/original/(nome)8.jpg ' );

Error:

Invalid property value

This happens because inside the URL there is a ")" that encloses the value of the url ()

How can I solve this?

I tried the following combinations in the template, without success:

<div style="background-image: url(  {{ obj.url }}  )"></div>
<div style='background-image: url( " {{ obj.url }} " )'></div>
<div style="background-image: url( ' {{ obj.url }} ' )"></div>
<div style='background-image: url(  {{ obj.url }}  )'></div>
Ricardo
  • 422
  • 3
  • 11
  • 22
  • Are you sure it's because of the parentheses? They should be legal in a URL. Your path also includes spaces before and after it, which is almost certainly an error. – ChrisGPT was on strike Dec 11 '16 at 19:02
  • Have you seen: http://stackoverflow.com/a/14378456/4974980 – Jens Astrup Dec 11 '16 at 19:02
  • @JensAstrup, what does that post have to do with anything? The OP here is only trying to set the background image, not position and repeat. – ChrisGPT was on strike Dec 11 '16 at 19:03
  • @Chris I can seed the error in Chrome f12 tool... In the style tab the URL is blue, when it arrives in the ")" it closes the URL and the rest (ignored) of the url goes black ... – Ricardo Dec 11 '16 at 19:17

1 Answers1

0

I found the problem.

Replace "(" with "%28" and ")" with "%29"

It works

Ricardo
  • 422
  • 3
  • 11
  • 22