Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BOOTSTRAP // not working despite adding cdn links and reference style link // PYTHON

I'm currently in the middle of building this Django app and after I got the main parts that I wanted which were the login page and the homepage working, I decided on updating the look of my page because it was VERY basic. I've used bootstrap a ton before and I'm in love with it. However, this problem to me is a first. As you will see down below I have linked bootstrap via CDN (TWICE) and also via reference stylesheet link. Despite all these different ways of getting bootstrap my page still looks like this

my page still looks like this.

Here is my base_generic.html

{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>

    {% block title %}<title>Local Library</title>{% endblock %}
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">-->
  <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>-->
  <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>-->


    <!-- Add additional CSS in static file -->
    {% load static %}
    <link rel="stylesheet" href="{% static 'css/styles.css' %}">
    <!--<img src="{% static 'catalog/images/local_library_model_uml.png' %}" alt="My image" style="width:555px;height:540px;"/>-->
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-3.3.7-dist/css/bootstrap.min.css' %}" />

</head>

<body>
    {% include "header.html" %}


    <div class="jumbotron">
        <div class="container">
            {% block content %}{% endblock %}
            {% include "pagination.html" %}
        </div>
    </div>
</body>
</html>

And here is my header.html file that has my navbar

{% load staticfiles %}

<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
      <a class="navbar-brand" href="#">Navbar</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item active">
            <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Link</a>
          </li>
          <li class="nav-item">
            <a class="nav-link disabled" href="#">Disabled</a>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
            <div class="dropdown-menu" aria-labelledby="dropdown01">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
            </div>
          </li>
        </ul>
        <form class="form-inline my-2 my-lg-0">
          <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
          <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
        </form>
      </div>
    </nav>

Heres what my file structure looks like

Framework

Any input or feedback would be helpful really. I'm really stuck here.

like image 985
X-TremeFighter12 Avatar asked Feb 25 '26 13:02

X-TremeFighter12


1 Answers

Add this to the settings.py file:

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
like image 125
jose frankoo Avatar answered Feb 27 '26 02:02

jose frankoo