0

I am using Django and have set up a view that returns a dynamically generated stylesheet to allow for user themes. I link the stylesheet in the head section of my pages with,

<link href="/theme.css" rel="stylesheet">

I can see the request for /theme.css at the server and a successful response. I can also view the source of the page in the browser and it shows the correct contents for the stylesheet.

However, for some reason the styles in theme.css are not applied to the page.

If I place the contents of the dynamically created stylesheet into a static file and change the link like so,

<link href="/static/rml/css/theme.css" rel="stylesheet">

the styles are correctly applied.

I can't see why there is a difference. I have looked for answers and can't find anything relevant.

M. Webb
  • 157
  • 11
  • You may have a mime type issue, see https://stackoverflow.com/questions/35557129/css-not-loading-wrong-mime-type-django Are there any errors in the browser console? – frnhr Mar 11 '20 at 01:10
  • I tried the change from the answer you mentioned and it made no difference. There are no errors in the console and the strange thing is that the dynamic css file must be being correctly created and served because I can access it through the browser by viewing source and then selecting the link to the theme.css file. – M. Webb Mar 11 '20 at 04:23

0 Answers0