Not able to display images from static folder using Django

2024/7/7 6:10:16

My OUTPUTThis is my home.html I'm not able to display the images in static/images/ folder. Although *[09/Mar/2020 15:52:09] "GET /static/images/mona.jpg HTTP/1.1" 404 1669 * is displayed in terminal.I have provided a screenshot of the directory so that in case any files are not misplaced by me, or in the wrong folder


<head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" />{% block content %}{% load static %}<title>Home</title><link rel="stylesheet" href={% static '/css/style.css' %} /><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" /><script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"crossorigin="anonymous"></script>
</head><body>{% include "includes/header.html" %}<div class="pt-5"><div class="card d-inline-block"><img src={% static 'images/mona.jpeg' %} alt="Avatar" style="width:100%;"><div class="container"><h4><b>Mona Lisa</b></h4><p><a href="#">Architect & Engineer</a></p></div></div><div class="card d-inline-block"><img src={% static "images/mona.jpg" %} alt="Avatar" style="width:100%"><div class="container"><h4><b>The Scream</b></h4><p><a href="#">Architect & Engineer</a></p></div></div></div>{% include "includes/footer.html" %}{% endblock content %}
</body>
Answer

add quotes around source as follows

{% load static %}<img src="{% static 'images/mona.jpeg' %}" alt="Avatar" style="width:100%;">
https://en.xdnf.cn/q/120014.html

Related Q&A

Regex to match phone number 5ABCDYYZZ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 1 year ago.Improve …

Remove an \\n\\t\\t\\t-element from list

I got the following list called "phonenumbers". I struggle to remove the elements which contain \n\t\t\t and \n\t\t\t\t. I tried "try and except"-methode and remove(\n\t\t\t\t) but …

Find all numbers in a string in Python 3 [duplicate]

This question already has answers here:How to extract numbers from a string in Python?(20 answers)Split Strings into words with multiple word boundary delimiters(31 answers)Closed 8 years ago.Newbie h…

call dictionary from one function to another

How can I call a dictionary created in one function to another?I have tried using How do I access a dictionary from a function to be used in another function? but it doesnt work for me.I have created…

How to change values in numpy array

import numpy as np a=np.array([[4,2,6],[3,6,5]]) b=np.array([3,5])I want to update the numbers in "a" which are bigger than the numbers in "b" to np.nan. If they are smaller or equa…

Why use the object oriented approach in matplotlib for visualizing data? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to repro…

Set a status for a discord bot

I am trying to get my bot to have the status, m!help. I see that a lot of other bots have their help command in their status so I wanted to do that too. await bot.change_presence(activity=discord.Game(…

Can you permanently change python code by input?

Im still learning python and am currently developing an API (artificial personal assistant e.g. Siri or Cortana). I was wondering if there was a way to update code by input. For example, if I had a lis…

Count the number of files with a special suffix in a directory using python

It is possible to count the number of all files in a directory by:import ospath = /mnt/BIGDATA/num_files = len([f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))])As mentioned in How…

How to not hardcode function in this example

The following links contain 2 csv files that the function should pass through grades_1e_2a grades_2e_4aHowever my function is only able to pass the 2nd linked file, as it is hardcoded to range(4,8). ou…