How do I 'href' bootstrap3 directory when I use django 1.8 framework?

233 views Asked by At

This is what my project directory looks like (significantly truncated to get to my point quickly):

├── bootstrap-3.3.5-dist
└── mysite
    ├── db.sqlite3
    ├── myApp
    │   ├── admin.py
    │   ├── forms.py
    │   ├── __init__.py
    │   ├── templates
    │   │   └── myApp
    │   │       ├── base.html
    │   │       ├── index.html
    │   ├── tests.py
    │   ├── urls.py
    │   └── views.py

I want to apply bootstrap style to mysite/templates/myApp/base.html, which is what I have below (only the section that has the href):

<head><link href="/css/bootstrap.min.css" rel="stylesheet"></head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</body>

So, I have tried to add various number of ../ in front of /css and /js, none of which worked. Can anyone tell me how I can apply my bootstrap css style to these html files when they are not at the same directory?

1

There are 1 answers

1
FlipperPA On BEST ANSWER

You currently have bootstrap in a non-web accessible location.

While you could extract the contents of bootstrap-3.3.5-dist/ to your Django project in static files, and reference it that way, there's a very easy to use Django app for using bootstrap3. You can find it here:

https://github.com/dyve/django-bootstrap3

You can install it with this command, and and it to your installed apps:

pip install django-bootstrap3

See the link for more details.