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.
{% load staticfiles %} <link rel="stylesheet" href="{% static user_stylesheet %}" type="text/css" media="screen"/>
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
{% load static %}
And then something like
<!-- path --> <link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet" type="text/css"> <!--->
Update for Completeness
Folder Structure
- proj
- app1
- app2
- myproj_public
- static
- css
- bootstrap.css
- js
- xyz.js
- css
Settings File
STATIC_ROOT = os.path.join(os.path.abspath( os.path.join(PROJECT_ROOT, 'myproj_public', 'static')), '') STATIC_URL = '/static/'