Necessary updates in settings.py
INSTALLED_APPS = [
'store.apps.StoreConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
main.html file
<!DOCTYPE html>
<html lang="en">
{% load static %}
<head>
<title>Ecom</title>
<meta charset="UTF-8">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6"
crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'css/main.css' %}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h2>main</h2>
(% block content %}
{% endblock %}
</body>
CSS file main.css
body {
background: #FF0000; }
also tried using !important (despite knowing it isn't a good practice)
The template I was trying to render, store.html
{% extends 'store/main.html' %}
{% load static %}
{% block content %}
<h1>color</h1>
{% endblock %}
page preview
The file directories,
src
-static
-css
-main.css
-store
-templates
-store
-main.html
-store.html
The problem is I cannot preview the customized background color of the body. Is the problem due to bootstrap, or my customized css attributes? Or is it the {% extend ...} is not working, or am I missing to add something in the settings.py. Just started learning Django, would be of great help if anyone make me clear the bug.