Okay I am working on my first website django project that is not a tutorial and I am thinking a carosuel would be a really great opening feature for my website home page.
So, I have bootstrap and I went to the website and I managed to get the code for inputting bootstrap into my project and the code for the carousel itself. The carousel needs images to rotate in and out.
Per Django for beginners I made a project level static folder and a css folder and than I made an images folder and placed my images in there. Like so:
static/css/images_folder and at the same level base.css.
I placed my three photos in the images folder.
Than I went to my base.html and input the load static tag just as it was in Django for beginners.
I also went to my django_project/settings.py and updated the values there to the following.
django_project/settings.py
# django_project/settings.py
STATIC_URL = "static/"
STATICFILES_DIRS = [BASE_DIR / "static"] # new
I went back to the carousel and in home.html filled in the image src with he following but it doesn’t work. I am thinking that either my path is wrong or my django is overriding it.
home.html
{% extends 'inventory/base.html' %}
{% load static %}
{% block content %}
{% block head %}
<link rel="stylesheet" href="{% static 'inventory/style.css' %}">
{% endblock %}
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous">
</head>
<h1>Welcome to the Home page!</h1>
<body>
<div id="carouselExampleAutoplaying" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="/static/css/images" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="/static/css/images" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="/static/css/images" class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleAutoplaying" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleAutoplaying" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</body>
<script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</script>
{% endblock %}
My folder structure is
djangodelights/inventory/templates/inventory/base.html etc all my templates
djangodelights/static/css//image1 and so on.
djangodelights/djangodelights/static/css/images/picture1,2,3 and so on
djangodelights/djangodelights/static/css/base.css