[Answered ]-How to use triple nested quotes in django tempates?

1πŸ‘

βœ…

It’s failing because you are using double quotes inside double quotes

Here is how it would look without the Django static files declaration

<div class="full-background" style="background-image: url('path/to/file')"></div>

Note the single quotes around the url path

If you want to use Django static files, just use single quotes outside and inside the static declaration

    <div 
       class="full-background" 
       style="background-image: url('{% static '/img/curved-images/white-curved.jpg' %}')"
    ></div>

Django will not see the outside single quotes when it looks for the static files.

πŸ‘€ja408

Leave a comment