Omar Jandali
Omar Jandali

Reputation: 824

Integration of css to Django templates

I have a django project and I have added and began integrating bootstrap into my project for the base template as well as other templates that contain the content. I want to know how I can integrate custom css from within my project to finer tune my project and how I want certain things to fit together. I will add the html base template as well as the directory that contans the files to give a reference.

Here is the html files:

{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
    <title>{% block title %}{% endblock %}</title>
    <link href="{% static "static/css/main.css" %}" rel="stylesheet">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
</head>
<body>
    <div id="content" class="container-fluid">
        {% block content %}
        {% endblock %}
    </div>
</body>
</html>

Here is the directory that I have for this project so you can get an idea of where the files are.

enter image description here

Upvotes: 1

Views: 596

Answers (1)

Astik Anand
Astik Anand

Reputation: 13057

You don't need " quotes for path and also as you have already specified you are looking in static folder by {% static you only need to give path after that static directory.

<link href="{% static 'css/main.css' %}" rel="stylesheet">

Upvotes: 1

Related Questions