Changing class of HTML element according to current file - html

I'm using Django and HTML files and I'm trying to change the class of one element depending on the current file.
So, I have this base.html file, which is some kind of "super-class" file, which most of my other .html extends, thanks to Django, using {% extends 'base.html' %}
Among other things, in that file, I have a navigation bar on top, which all files must have. This navigation bar has various elements, one of them being the current active element. For example, in the "foo.html" page, I'd like the navigation bar element holding to 'foo' tab to be underlined in red. I have a .css class for this, I just type class="active" and I'm good to go.
But I'm in base.html. I can't. If I do, it's obviously active for every single child.
Is there a solution for this or am I SOL?
To be clear, I want foo.html to somehow tell base.html that "this div" should be active, while other files will tell base.html differently.
Also, I would like some kind of clean solution, this is a long lasting project and I'd rather not start with any hacks. I know I could duplicate the navigation bar in all my files and set the correct button to active on each separate file, but this can't be the way to go.
Here is the code i'm using :
{% extends 'base.html' %}
{% load static %}
{% block content %}
<!-- #### -->
<!-- Menu -->
<!-- #### -->
<div id="nav-content">
<nav>
<div class="row">
<div class="col s12">
<!-- ############ -->
<!-- Desktop Menu -->
<!-- ############ -->
<div class="nav-wrapper">
<a href="home" class="brand-logo">
<img src="{% static 'notifications/img/logo.png' %}"/>
<span class="valign">
<b class="main-text">NotifyMe</b> - Hello World :)
</span>
</a>
<!-- Desktop -->
<ul class="right hide-on-med-and-down">
Should be class="active" here
<li>Feeds</li>
<li>Profile</li>
<li>Logout</li>
</ul>
<!-- Mobile -->
<a href="#" data-activates="mobile-demo" class="button-collapse">
<i class="material-icons">menu</i>
</a>
</div>
<!-- ########### -->
<!-- Mobile Menu -->
<!-- ########### -->
<ul class="side-nav" id="mobile-demo">
<li class="logo">
<img src="{% static 'notifications/img/logo.png' %}"/>
<p>
<b class="main-text">Aero</b> Admin
</p>
</li>
<li>
<a class="waves-effect" href="manage_feeds">Feeds</a>
<a class="waves-effect" href="profile">Profile</a>
<a class="waves-effect" href="logout">Logout</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
{% block innerContent %}
{% endblock %}
{% endblock %}

Related

Bootstrap navbar dropdown not working due to FlexStart css

I know this is a very common issue; however, this one is peculiar. When I use just the regular CSS style sheets (so without style.css), everything works fine, but as soon as I input in main.css, the dropdown stops working. I have no idea which specific part of the CSS is throwing off the dropdown so I am asking for help. I am using Django templates and if I include the style.css on just the home.html page then the dropdown only doesn't work there. I want to try and keep the FlexStart template so I would appreciate the help.
base.html
{% load static i18n %}<!DOCTYPE html>
{% get_current_language as LANGUAGE_CODE %}
{% load bootstrap_icons %}
<html lang="{{ LANGUAGE_CODE }}">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>{% block title %}Semiconnect{% endblock title %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Behold My Awesome Project!">
<meta name="author" content="Dilreet Raju">
<link rel="icon" href="{%static 'images/favicons/favicon-32x32.png' %}">
{% block css %}
{% load static %}
<!-- Latest compiled and minified Bootstrap CSS -->
<!-- Latest compiled and minified Bootstrap CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/css/bootstrap.min.css" integrity="sha512-GQGU0fMMi238uA+a/bdWJfpUGKUkBdgfFdgBm72SUQ6BeyWjoY/ton0tEjH+OSH9iP4Dfh+7HM0I9f5eR0L/4w==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Your stuff: Third-party CSS libraries go here -->
<!-- This file stores project-specific CSS -->
<link href="{% static 'css/project.css' %}" rel="stylesheet">
<link href="{% static 'css/carousel.css'%}" rel="stylesheet">
<link href="{% static 'css/style.css'%}" rel="stylesheet">
{% endblock %}
<!-- Le javascript
================================================== -->
{# Placed at the top of the document so pages load faster with defer #}
{% block javascript %}
<!-- Bootstrap JS -->
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/js/bootstrap.min.js" integrity="sha512-OvBgP9A2JBgiRad/mM36mkzXSXaJE9BEIENnVEmeZdITvwT09xnxLtT4twkCa8m/loMbPHsvPl0T8lRGVBwjlQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- Your stuff: Third-party javascript libraries go here -->
<!-- place project specific Javascript in this file -->
<script defer src="{% static 'js/project.js' %}"></script>
{% endblock javascript %}
</head>
<body class="pt-0 pb-0 mb-0">
<header class="pt-0 pb-0">
<nav class="navbar navbar-expand-md navbar-light pl-3 bg-light">
<div class="container-fluid">
<button class="navbar-toggler navbar-toggler-right" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="{% url 'stackbase:home' %}"><h1 id='Titlefont'style='color:#4154F1'>Semi<span class="text-black" id='Titlefont'>Connect</h1></a>
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
<ul class="navbar-nav ">
<li class="nav-item active">
<a class="nav-link" href="{% url 'stackbase:home' %}"><h6>Home</h6> <span class="visually-hidden">(current)</span></a>
</li>
</li>
{% if request.user.is_authenticated %}
<li class="nav-item ">
<a class="nav-link" href="{% url 'stackbase:question-create' %}"><h6>Ask A Question</h6></a>
</li>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'stackbase:question-lists' %}"><h6>View Questions</h6></a>
</li>
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a class="nav-link" href="{% url 'users:detail' request.user.username %}"><h6>{% translate "My Profile" %}</h6></a>
</li>
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a class="nav-link" href="{% url 'account_logout' %}"><h6>{% translate "Sign Out" %}</h6></a>
</li>
{% else %}
{% if ACCOUNT_ALLOW_REGISTRATION %}
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a id="sign-up-link" class="nav-link" href="{% url 'account_signup' %}"><h6>{% translate "Sign Up" %}</h6></a>
</li>
{% endif %}
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a id="log-in-link" class="nav-link" href="{% url 'account_login' %}"><h6>{% translate "Sign In" %}</h6></a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
{% if messages %}
{% for message in messages %}
<div class="alert alert-dismissible {% if message.tags %}alert-{{ message.tags }}{% endif %}">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endif %}
</div> <!-- /container -->
{% block content %}
<p>Use this document as a way to quick start any new project.</p>
{% endblock content %}
{% block modal %}{% endblock modal %}
<!-- Footer -->
<!-- Footer -->
{%if not now%}
<footer class="text-center text-lg-start bg-light text-muted">
<!-- Section: Social media -->
<!-- Section: Social media -->
<!-- Section: Links -->
<section class="">
<div class="container text-center text-md-start mt-5 pt-4">
<!-- Grid row -->
<div class="row mt-3">
<!-- Grid column -->
<div class="col-md-3 col-lg-4 col-xl-3 mx-auto mb-4">
<!-- Content -->
<h6 class="text-uppercase fw-bold mb-4">
<i class="fas fa-gem me-3"></i>Semiconnect
</h6>
<p>
Learn the ropes as you ask questions from seniors who are happy to help.
</p>
</div>
<!-- Grid column -->
<!-- Grid column -->
<!-- Grid column -->
<!-- Grid column -->
<div class="col-md-3 col-lg-2 col-xl-2 mx-auto mb-4">
<!-- Links -->
<h6 class="text-uppercase fw-bold mb-4">
Useful links
</h6>
<p>
Back To Top
</p>
<p>
Ask A Question
</p>
<p>
View Questions
</p>
<p>
Sign Up
</p>
<p>
Sign In
</p>
</div>
<!-- Grid column -->
<!-- Grid column -->
<div class="col-md-4 col-lg-3 col-xl-3 mx-auto mb-md-0 mb-4">
<!-- Links -->
<h6 class="text-uppercase fw-bold mb-4">Contact</h6>
<p><i class="fas fa-home me-3"></i> Surrey, BC, 13153 64 ave</p>
<p>
<i class="fas fa-envelope me-3"></i>
dilreetraju#gmail.com
</p>
<p><i class="fas fa-phone me-3"></i> + 01 778 807 0609</p>
<p><i class="fas fa-print me-3"></i> + 01 604 356 3123</p>
</div>
<!-- Grid column -->
</div>
<!-- Grid row -->
</div>
</section>
<!-- Section: Links -->
<!-- Copyright -->
<div class="text-center p-4" style="background-color: rgba(0, 0, 0, 0.05);">
© 2022 Copyright: Semiconnect
</div>
<!-- Copyright -->
</footer>
{%endif%}
<!-- Footer -->
{% block inline_javascript %}
{% comment %}
Script tags with only code, no src (defer by default). To run
with a "defer" so that you run inline code:
<script>
window.addEventListener('DOMContentLoaded', () => {/* Run whatever you want */});
</script>
{% endcomment %}
{% endblock inline_javascript %}
</body>
</html>
I cannot include the CSS file in the post but here is the paste bin link. https://pastebin.com/G5G0pcM1 I appreciate the support.

CSS does not work in inherited Django template

I have two page templates and a CSS file in static directory.
This is my main.html where CSS works just fine:
{% load static %}
<html>
<head>
<title> </title>
<link rel ="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
<nav>
<ul>
<li><img src="{% static 'images/logo.jpg'%}" height="49px" width="100px" >
<li><a href=#> HOME</a></li>
<li><a href=#> ABOUT</a></li>
<li> RENT</li>
<li> SALES</li>
</ul>
</nav>
{% block content %}
{% endblock %}
</body>
<hr>
<footer>
This is my index.html where CSS does not work:
{% extends 'main.html' %}
{% block content %}
<div id="showcase">
<div class="section-main container" >
<h1>House rent & Sale</h1>
<p class="lead hide-on-small">This is a web application </p>
</div>
</div>
{% endblock%}
How can I solve this?
Move your {% block content %}to above the header in main.html

How to position content beside sidebar?

I am not very well versed in HTML and CSS. I am currently building a web application using Django and I integrated a sidebar into my web application using Bootstrap, but it has messed my layouts, and I can't seem to figure out how to move the content in a block to the left of side of my sidebar.
As seen in the pictures above, my sidebar is located at the top and my content is located at the bottom. Below are my codes for my sidebar and the base template.
sidebar_template.html
<div class="d-flex flex-column vh-100 flex-shrink-0 p-3 text-white bg-dark sidebar-height" style="width: 250px;"> <svg class="bi me-2" width="40" height="32"> </svg> <span class="fs-4">CPRS Admin</span>
<hr>
<ul class="nav nav-pills flex-column mb-auto">
<li class="nav-item"> <i class="fa fa-home"></i><span class="ms-2">Home</span> </li>
<li> <i class="fa fa-dashboard"></i><span class="ms-2">Dashboard</span> </li>
<li> <i class="fa fa-first-order"></i><span class="ms-2">Students</span> </li>
<li> <i class="fa fa-cog"></i><span class="ms-2">Settings</span> </li>
<li> <i class="fa fa-bookmark"></i><span class="ms-2">Bookmarks</span> </li>
</ul>
<hr>
<div class="dropdown"> <img src="https://github.com/mdo.png" alt="" width="32" height="32" class="rounded-circle me-2"> <strong> John W </strong>
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
<li><a class="dropdown-item" href="#">New project</a></li>
<li><a class="dropdown-item" href="#">Settings</a></li>
<li><a class="dropdown-item" href="#">Profile</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Sign out</a></li>
</ul>
</div>
</div>
base.html
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>Capstone Project</title>
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="{% static 'css/main.css' %}" rel="stylesheet">
<link href="{% static 'css/profile.css' %}" rel="stylesheet">
<link href="{% static 'css/sidebar.css' %}" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<div class="page-container">
<div class="content-wrap">
<div class="">
{% if user.is_authenticated and user.is_superuser %}
{% include 'HOD/sidebar_template.html' %}
{% endif %}
</div>
<div class="col">
{% block content %}
{% endblock content %}
</div>
</div>
</div>
<!-- Optional Javascript -->
{% block custom_js %}
{% endblock custom_js %}
</body>
<!-- Site footer -->
<footer class="footer">
<div class="container text-center">
<small>Copyright © Your Website</small>
</div>
</footer>
</html>
Can someone help me fix the layouts ? Thanks.
This is a bootstrap issue, not a django issue.
You have to wrap your head around how the bootstrap grid works.
You have to first create a row element which can contain one or more columns. When you create the columns you get to decide their behavior according to screen size, or to just let them figure out their sizing by themselves.
This will create two equally sized columns that will take up whatever width space available.
<div class="row">
<div class="col">
content
</div>
<div class="col">
content
</div>
</div>
If you want to define the width of each column in relation to the total width of the page, you can define that when you create the columns. Here you can specify different behaviors for different screen sizes in order to make your site responsive.
<div class="row">
<div class="col-3 col-lg-2">
This column will be 3/12 of the screen on small and medium screens. Or 2/12 of the screen on large screens and up.
</div>
<div class="col-9 col-lg-10">
This column will be 9/12 of the screen on small and medium screens. Or 10/12 of the screen on large screens and up.
</div>
</div>
And in your specific case i'd suggest something like this:
<div class="page-container">
<div class="content-wrap">
<div class="row">
<div class="col-3">
{% if user.is_authenticated and user.is_superuser %}
{% include 'HOD/sidebar_template.html' %}
{% endif %}
</div>
<div class="col-9">
{% block content %}
{% endblock content %}
</div>
</div>
</div>
</div>

Materialize css sidenav not working in django

I am trying to create a navbar and sidenav from materialize css in django. Created three main html files with the name of mbase.html, navbar.html and sidenav.html. below are the codes respectively.
mbase.html:
{%load materializecss %}
{% load static %}
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!--custom css for materialize-->
<link rel="stylesheet" type="text/css" href= {% static 'css/style.css' %}>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!--Title of the page goes here-->
<title>{% block title %}Hello World {% endblock title %}</title>
</head>
<body>
{% include 'navbar.html' %}
{% block body %}
{% endblock body %}
<!--Jquery optional-->
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type="text/javascript" src={% static 'js/main.js' %}></script>
</body>
</html>
navbar.html:
{% load static %}
<nav>
<div class="nav-wrapper">
<i class="material-icons">menu</i>
CMMS
<ul class="right hide-on-med-and-down">
<!-- Dropdown Trigger for userprofile -->
{% if request.user.is_authenticated %}
<li><a id="userdropdown" class="dropdown-trigger" href="#!" data-target="dropdown2" >Hello, {{ request.user.email }}<i
class="material-icons right">arrow_drop_down</i></a></li>
{% else %}
<li>Login</li> | <li>Registration</li>
{% endif %}
<li>Company</li>
<li>About Us</li>
<!-- Dropdown Trigger for links dept wise -->
<li><a class="dropdown-trigger" href="#!" data-target="dropdown1">Department<i
class="material-icons right">arrow_drop_down</i></a></li>
</ul>
</div>
<ul id="dropdown1" class="dropdown-content">
<li>E&M</li>
<li>Finance</li>
<li class="divider"></li>
<li>Personnel</li>
</ul>
<ul id="dropdown2" class="dropdown-content">
<li>Logout</li>
</ul>
</nav>
{% include 'sidenav.html' %}
sidenav.html:
<ul id="slide-out" class="sidenav">
<li><div class="user-view">
<div class="background">
<img src="images/office.jpg">
</div>
<img class="circle" src="images/yuna.jpg">
<span class="white-text name">John Doe</span>
<span class="white-text email">jdandturk#gmail.com</span>
</div></li>
<li><i class="material-icons">cloud</i>First Link With Icon</li>
<li>Second Link</li>
<li><div class="divider"></div></li>
<li><a class="subheader">Subheader</a></li>
<li><a class="waves-effect" href="#!">Third Link With Waves</a></li>
</ul>
and in the main.js:
$(document).ready(function(){
$('.sidenav').sidenav();
// Initialize materialize data picker
$('.datepicker').datepicker({'format': 'yyyy-mm-dd'});
$('select').formSelect();
// other functions to make it collapsible
$('.collapsible').collapsible();
$(".dropdown-trigger").dropdown();
$("#userdropdown.dropdown-trigger").dropdown({coverTrigger: false});
});
Please help me i don't know why sidenav bar is not working.
while inspect in browser it show like. while pressing the sidenav menu its not expand.
use the following code in the beginning of your sidenav HTML template:
{% extends 'mbase.html' %}
Your CDN is not importing to your nav HTML file so this code will help you inherit the page

Django templates with CSS file not working

I am learning about templates for my project (I am creating a web app using the Django framework with HTML and CSS). However, I have hit a snag. I did try to link the CSS file to the base HTML file (which is the parent template that my other templates inherit from) and my CSS updates aren't reflecting on the home page to my browser.
Is there a problem with the link? The indentations are okay and there are no errors on my code. I have also tried to rerun my server and nothing. The "main.css" file is in the static subdirectory which is inside the blog directory and my app is called "Brenda's Blog".
The code in my base.html file is below, inclusive of the link linking the main.css file.
My CSS file: blog/static/main.css
{% load static %}
<!-- will load css file from static directory -->
<!DOCTYPE html> {% load static %}
<!-- will load css file from static directory -->
<!DOCTYPE html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}">
{% if title %}<!-- django for loop for when the user clicks on to different pages -->
<title>Brenda's Blog - {{ title }}</title>
{% else %}
<title>Brenda's Blog</title>
{% endif %}
</head>
<body>
<!-- added navigation bar with bootstrap css classes to decorate the website -->
<header class="site-header">
<nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
<div class="container">
<a class="navbar-brand mr-4" href="/">Brenda's Blog</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggle">
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link" href="/">Home</a>
<a class="nav-item nav-link" href="/about">About</a>
</div>
<!-- Navbar Right Side -->
<div class="navbar-nav">
<a class="nav-item nav-link" href="#">Login</a>
<a class="nav-item nav-link" href="#">Register</a>
</div>
</div>
</div>
</nav>
</header>
<main role="main" class="container">
<div class="row">
<div class="col-md-8">
{% block content %}{% endblock %}
</div>
<div class="col-md-4">
<div class="content-section">
<h3>Our Sidebar</h3>
<p class='text-muted'>You can put any information here you'd like >
<ul class="list-group">
<li class="list-group-item list-group-item-light">Latest Posts</li>
<li class="list-group-item list-group-item-light">Announcements</li>
<li class="list-group-item list-group-item-light">Calendars</li>
<li class="list-group-item list-group-item-light">etc</li>
</ul>
</p>
</div>
</div>
</div>
</main>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
</body>
</html>
Welcome to Stackoverflow.
Make sure your settings.py file have the following configuration.
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_DIR = os.path.join(BASE_DIR,'static')
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
STATIC_DIR,
]
Then run,
python manage.py collectstatic
This command will collect static files from your all of your django applications into a single directory called staticfiles which will also benefit you when you will be deploying your project.
Then load staticfiles in the beginning of your template.
{% load staticfiles %}
Don't forget to clear cache of your browser, press ctrl+F5 to ignore the cached content when refreshing.
First, clear your cache and hard refresh the browser. If it doesn't work then go for the following steps.
Check your settings.py file for correct configurations to access the static files. The code should look like this in the settings.py file.
STATIC_URL = '/static/'
STATIC_ROOT= os.path.join(BASE_DIR,'static')
Then your project structure should be like
app > static > app name(folder name same as app name) > main.css
So if your app name is blog. Then the structure should be like
blog > static > blog > main.css
After doing the changes hard refresh your browser, clear cache, go to Network tab ( clicking inspect element) and check whether you are getting CSS file on request and all the changes are getting reflected.
You should replace
{% load static %}
<!-- will load css file from static directory -->
<!DOCTYPE html> {% load static %}
<!-- will load css file from static directory -->
<!DOCTYPE html>
with
{% load static %}
<!DOCTYPE html>