In the management of views usually have a basic template and declare the section that is going to be modified (Usually the body
) This so that all your views have the same structure and only extend the properties of the principal. I'll give you an example.
What's that good for you?
In the template principal.html
you can add your logo, so you're not replicating it everywhere
The only thing I do not understand is that you are declaring in the css a selector called ody
whereby I will place it as a tag. Remember that you must call the variable static de Django
so that the relative routes are easier, this is so that you call your style.css
.
This would be your main template and it is called principal.html
, in the div .container
we will open a block from which later the other views can be fed. I'll call the block contenido
{%load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<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">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!--Aquí incluyes tu archivo style.css-->
<link rel="stylesheet" href="{% static '/nombre_app/style.css' %}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="jumbotron text-center">
<h1>My First Bootstrap Page</h1>
<p>Resize this responsive page to see the effect!</p>
<!--Aquí está tu etiqueta que tedrá la imagen como logo-->
<ody></ody>
</div>
<div class="container">
{% block contenido %}
{% endblock %}
</div>
</body>
</html>
That way you can include all this in your other views. For example in ventas.html
. The route from where you must extend is the name of your App (Not the project) and the template principal.html
{% extends 'nombre_app/principal.html' %}
{% block content %}
<!--Aquí todo tu contenido de ventas -->
{% endblock %}
I hope you serve, greetings.