I can load CSS files, which is stored in static folder. However, when I try to set background image in the CSS file. I failed.
I used URL({{ STATIC_URL }}images/img01.jpg)
in css, but it didn't load the image.
I can load CSS files, which is stored in static folder. However, when I try to set background image in the CSS file. I failed.
I used URL({{ STATIC_URL }}images/img01.jpg)
in css, but it didn't load the image.
You should always use relative paths in your css. Eg. url(../images/img01.jpg)
or url(images/img01.jpg)
depending on the location of your css file.
Static files are not processed by the template rendering engine, therefore you cannot use context variables or any other django templating syntactic elements. You should think your static files as files being served "as is", with no intermediate python or other processing.