Skip to content
Advertisement

Django – referencing static files in templates

I’m having difficulty referencing static files in my templates. I am using Twitter Bootstrap and have the bootstrap files (css, img, js) sitting at mysite/static.

I have set the STATIC_URL, STATIC_ROOT and TEMPLATE_CONTEXT_PROCESSORS according to this tutorial. I have run ./manage.py collectstatic which copied 72 files over. I have also added the below template tag to my template (index.html) file but this hasn’t worked.

JavaScript

Any help on how to reference the files so that the bootstrap styling returns to the templates would be much appreciated!

Advertisement

Answer

It should be

JavaScript

And then something like

JavaScript

Update for Completeness

Folder Structure

  • proj
  • app1
  • app2
  • myproj_public
  • static
    • css
      • bootstrap.css
    • js
      • xyz.js

Settings File

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement