2

I am using flask and Jinja templates. None of my CSS is being applied, except for bootstrap which is being downloaded from an external host.

Here is the line in my base template for my own stylesheet:

<link rel=”stylesheet” type=”text/css” href="{{ url_for('static', filename='style/stylesheet.css') }}">

And then when I open the page in chrome I can follow the link, and it opens up the file successfully. However when I look in the frames I cannot see my stylesheet under the stylesheets section:

enter image description here enter image description here

Here is the request from the server: GET /static/style/stylesheet.css HTTP/1.1" 200 -

It looks likes it's not being recognized as a css file ? I'm not great with web stuff so hopefully this is something simple.

Sherlock
  • 5,557
  • 6
  • 50
  • 78
  • What does the final HTML look like? Does it include the (expected) correct path to the CSS? – Simeon Visser Dec 04 '13 at 10:55
  • Yes, and when I view the source in chrome and follow the link it loads correctly. – Sherlock Dec 04 '13 at 10:57
  • That sounds unlikely? If the CSS is accessible then it can be loaded separately but also on the HTML page itself. Are you sure the path to the CSS is complete (i.e., `/` at the beginning, with static etc)? Alternatively, could you look in Chrome's web debugger to see how it returns the file (as text/css or something else)? – Simeon Visser Dec 04 '13 at 10:59
  • I also faced this kind of issue sometime back. Try restarting your computer. It worked for me. – Praful Bagai Dec 04 '13 at 11:10
  • Tried a restart, no luck unfortunately. – Sherlock Dec 04 '13 at 11:23
  • Must be a mystery. Try to solve it yourself, afterall your name is Sherlock. ;) – Praful Bagai Dec 04 '13 at 11:35
  • does a 404 page appear when you open the address to your css file on your browser ? for example : xx.com/static/style/stylesheet.css – Odai Al-Ghamdi Dec 04 '13 at 15:24

2 Answers2

1

I have no idea what was happening here. This issue has been ongoing for days.

To fix it I simply copied the line that loads the CSS, saved my project, pasted it back in, and ran the server. Mass confusion.

Sherlock
  • 5,557
  • 6
  • 50
  • 78
  • 1
    This is driving me crazy. I'm hitting the same thing and nothing works, copy-pasting included. Any idea what could be wrong? This seems like such a simple problem :-/ – mart1n Mar 31 '15 at 20:52
  • Turns out it was a faulty CCS from bootstrap's site. Odd. – mart1n Apr 03 '15 at 12:51
1

For anyone else still having issues with this I found this that suggests the CSS is not being "hard refreshed".

I fixed this issue on my Mac in Chrome by holding down both ⌘ Cmd+⇧ Shift and pressing R.

LockieR
  • 370
  • 6
  • 19