Bootstrap Navbar Logo not found

2024/9/20 9:39:41

Hello I am trying to get my NavBar on bootstrap to show a Logo, I have tried moving the png to different folders in the app but I get this error:

System check identified no issues (0 silenced).
January 21, 2022 - 18:18:54
Django version 4.0.1, using settings 'mapproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[21/Jan/2022 18:19:00] "GET / HTTP/1.1" 200 229230
Not Found: /logo.png
[21/Jan/2022 18:19:00] "GET /logo.png HTTP/1.1" 404 2219

Here is the index.html:

  <!--Navbar-->
<!-- Just an image -->
<!-- Image and text -->
<nav class="navbar navbar-dark bg-dark"><a class="navbar-brand" href="#""><img src="logo.png" width="30" height="30" class="d-inline-block align-top" alt=""/>EtherWAN Product Map</a>
</nav>
<!--End Navbar-->
Answer

"static" folders are needed in Django like in flask. https://docs.djangoproject.com/en/4.0/howto/static-files/

put your image in the static folder and call: static/logo.png instead of logo.png.

file structure:

enter image description here

HTML File Code Example:

{% load static %}{% block content %}<!--Navbar--><!-- Just an image --><!-- Image and text --><nav class="navbar navbar-dark bg-dark"><a class="navbar-brand" href="#""><img src="{% static 'posts/images/logo.png' %}" width="30" height="30" class="d-inline-block align-top" alt=""/>
EtherWAN Product Map
</a>
</nav>
<!--End Navbar-->    
{% endblock content %}

the file structure can be mainapp/ -> static/ -> images/ logo.png

https://en.xdnf.cn/q/119343.html

Related Q&A

Why camelcase not installed?

i try to install camelcase in my python project. pip install camelcase but when i want to use the package, pylance give me this error: Import "camelcase" could not be resolved Pylance (report…

Find the two longest strings from a list || or the second longest list in PYTHON

Id like to know how i can find the two longest strings from a list(array) of strings or how to find the second longest string from a list. thanks

Which tensorflow-gpu version is compatible with Python 3.7.3

Actually, I am tired of getting "ImportError: DLL load failed" inWindows 10 CUDA Toolkit 10.0 (Sept 2018) Download cuDNN v7.6.0 (May 20, 2019) / v7.6.4 tensorflow-gpu==1.13.1 / 1.13.2 / 1.14 …

Find valid strings [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 6…

What is the difference in *args, **kwargs vs calling with tuple and dict? [duplicate]

This question already has answers here:What does ** (double star/asterisk) and * (star/asterisk) do for parameters?(28 answers)Closed 8 years ago.This is a basic question. Is there a difference in doi…

Get result from multiprocessing process

I want to know if is there a way to make multiprocessing working in this code. What should I change or if there exist other function in multiprocessing that will allow me to do that operation.You can c…

How to do a second interpolation in python

I did my first interpolation with numpy.polyfit() and numpy.polyval() for 50 longitude values for a full satellite orbit.Now, I just want to look at a window of 0-4.5 degrees longitude and do a second …

How can I filter an ms-access databse, using QSqlTableModel and QLineEdit?

Im building a GUI that allows users to search information in a ms access database (yup. It has to be the ms access) The user has a textfield where he can type his search and the Tableview should update…

Python regex - Replace single quotes and brackets

Id like to replace quantities with name then a square bracket and a single quote with the contents inside. So, from this: RSQ(name[BAKD DK], name[A DKJ])to this:RSQ(BAKD DK, A DKJ)

Python unexpected EOF while parsing (python2.7)

Heres my python code. Could someone show me whats wrong with it? I try to learn an algorithm on solving 24 - point game. But I really dont know why this program has an error.from __future__ import div…