I have checked a links for how to set an image as background for a div
. I have tried various ways. But still am going wrong somewhere and would need some guidance...
Below is my directory structure:
frontend
/frontend (django project)
settings.py
.
.
/webApp (django app)
/templates
/static
img1.jpg
home.html
In my home.html
I have the following line,
{% load static %}
<div style="background-image: url({% static "/img1.jpg"%}); height: 650px; width: 1920px;">
In settings.py
I have,
STATIC_URL = '/static/'
But the image does not appear when the page is displayed. I get the following error.
"GET /static/img1.jpg HTTP/1.1" 404 1803
My directory structure was different and have searched a few questions before to fit my need. I still am getting confused with the urls and assigning url for the background image. Also i want it as a url
and not as href
to set the background-image
.
How do I go about this?