I've followed the django official document to set the static path. Document
I delete the isolated css file and put the style in my HTML file. It seems that the HTML file get the style successfully.
In my setting.py, I confirmed that
STATIC_URL = '/static/'
is there as default.
I create a new folder called static under my app folder where render this HTML page and also create the same folder under my project, I keep the content all the same in both of them because I was not sure which one really is the "static" path it recognized.
The image just doesn't appear.
I tried the solution here Add background image in css, and it doesn't at all.
I tried:
header.masthead {
position: relative;
background-color: #343a40;
background: url("../static/img/main.jpg") no-repeat center center;
background-size: cover;
padding-top: 8rem;
padding-bottom: 8rem;
}
It doesn't work
Please help me. Thanks!
Edit, this is my file structure: I get rid of the isolated CSS file and copy everything into the HTML file. Now it has the CSS style, but still can not get images.
MyProject
├── static
│ └──img
│ └── img_I_want_to_use_as_background.jpg
├── app
│ └── static
│ │ └──img
│ │ └── img_I_want_to_use_as_background.jpg
│ └── views.py (renders the HTML file)
│ └── other files and dirs under the app