Django Ignoring CSS

I just wasted a couple of hours trying to fix a total n00b Django mistake, so if you happen to Google “Django ignore CSS” or “Django not loading CSS”, maybe you’ll find this and it will save you time.

My mistake…I instictively put all of my <link> statements at the top of my template. It did not occur to me that since my homepage template was extending a theme template, Django will simply ignore anything that is not inside of a {% block %} tag that corresponds to a tag in a higher level theme. (I.e. if “theme_base.html” has {% block stuff %}{% endblock %}, you can replace that in “homepage.html” with {% block stuff %}HELLO WORLD{% endblock %}. But if you try to do {% some_random_new_block %} in homepage.html, or even worse put html outside of a block, it will be completely ignored!)

I just moved all my link statements into a valid block, and suddenly everything worked!

Leave a Reply

Your email address will not be published. Required fields are marked *