Reputation: 41
I extended the base file and the directory is correct and Iam still getting normal style.
{% extends "music/base.html" %}
{% block body %}
{% load staticfiles %}
<img src="{% static 'music/image/Robot-PNG-File.png' %}" class="rounded-circle" alt="face" style='max-height:200px'><br>
<h2>{{album.album_title}}</h2>
<h3>{{album.artist}}</h3>
<ul>
{% for songs in album.song_set.all%}
<li>{{songs.song_title}}- {{songs.file_type}}</li>
{% endfor %}<br>
</ul>
{% endblock %}
This is the base html.I copied this from bootstrap 4.0.I included the static files of bootstrap also.yesterday it worked fine.But today its not working
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Isai</title>
{% load staticfiles %}
<link rel="stylesheet" href="{% static 'personal/css/bootstrap.min.css' %}" type = "text/css"/>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300,700' rel='stylesheet' type='text/css'
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<link rel="stylesheet" href="{% static 'music/Stylesheet.css' %}" type = "text/css"/>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<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="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<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>
</div>
</nav>
{% block body %}
{% endblock %}
</body>
</html>
Upvotes: 1
Views: 1034
Reputation: 3610
Seems like you are storing the templates and static assets at the same directory:
{% extends "music/base.html" %}
<link rel="stylesheet" href="{% static 'music/Stylesheet.css' %}" type = "text/css"/>
Since you mentioned the template is loading, I guess the music
folder is your templates folder.
What you have to do is create a folder for your static assets (css, js, etc.).
Usually we store it at:
/static/css/
It's also a good idea to store them in different places.
After you do that, move your Stylesheet.css
file to /static/css/
.
And don't forget to add this folder to the STATICFILES_DIRS
configuration in your settings.py.
settings.py
STATICFILES_DIRS = (
os.join(BASE_DIR, 'static'),
)
Then you can update your css reference:
<link rel="stylesheet" href="{% static 'css/Stylesheet.css' %}" type = "text/css"/>
You can read more about static files management on the docs.
Upvotes: 3