[Django]-Django + skelJS / Static Files Issue / References to Images in CSS

4๐Ÿ‘

โœ…

Ok folks, I was correct, this was not related to Django at all and for that I apologize.

For any readers who use skelJSโ€ฆ

After beautifying/de-minimizing the code, look for:

newStyleSheet: function (a) {
    var c = document.createElement("link");
    c.rel = "stylesheet";
    c.type = "text/css";
    c.href = a;
    return c
},

Then, replace c.href = a; with c.href = "/static/" + a; where โ€œ/static/โ€ is your STATIC_URL defined in settings.py.

๐Ÿ‘คmjhasbach

0๐Ÿ‘

Use relative paths to your images. They are relative to where the css file lives. So, if a background-image declaration in STATIC_ROOT/css/style.css needs to reference bg02.jpg in STATIC_ROOT/images/bg02.jpg it should be declared like background-image: url(../images/bg02.jpg)

๐Ÿ‘คtoad013

Leave a comment