I tried my best to ...
 
Notifications
Clear all

I tried my best to configure as static the background :url , but failed

7 Posts
2 Users
0 Reactions
66 Views
0
Topic starter

Reference Section: 03 part

Homepage And Static Files Configuration

I tried my best to configure the following code as static.

```background: url(extra-images/bg-image1.jpg)```
 
 
The following error occurs
  • "GET /static/extra-images/bg-image1.jpg HTTP/1.1" 200 189817
Sir, what is the best way to configure it as static

 

2 Answers
0

Hi Ejaz Ali Inayat

The issue you are facing, I believe, is not related to static files. However, to provide proper guidance, I need to see your GitHub repository. Please share your GitHub repository with us and explain how the static files are configured in your project.

There are several ways to manage the static files and also depend on project requirements .For this project, the following are the best practices for managing static files:

STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR /'static'
STATICFILES_DIRS = [
'foodOnline_main/static'
]
Ejaz Ali Inayat Ejaz Ali Inayat Topic starter 31/12/2024 2:12 am

@mohaiminul-islam https://github.com/webextolcollege/foodonline.git

url(extra-images/bg-image1.jpg) not loaded from static file

0

Hi Ejaz Ali Inayat

The issue you're encountering is because, in the background-url property where you define the image URL, you are not using the static tag. That is the reason it's not working. You only need to add the static tag there, like this:

background: url({% static 'extra-images/bg-image1.jpg' %}) no-repeat center / cover;

 

After adding the static tag, your issue should be resolved. For your convenience, here’s the complete line of code:

<div class="page-section nopadding cs-nomargin main-search-bar" style="padding-top: 200px; padding-bottom: 150px; margin-bottom: 0px; background: url({% static 'extra-images/bg-image1.jpg' %}) no-repeat center / cover;">

 

If you need any further assistance, feel free to ask. We’d be happy to help! 

Ejaz Ali Inayat Ejaz Ali Inayat Topic starter 31/12/2024 9:23 pm

@mohaiminul-islam Sir, I tried my best but the issue remains the same. my GitHub link is under

https://github.com/webextolcollege/foodonline.git

Kindly teach me where I made a mistake

IMG 1866 rathank.com Mohaiminul - Team Rathan 01/01/2025 4:40 pm

Hi, I have added the same static in the background URL, and it's working on my system. However, the GitHub repository you provided is not updated. Please share the updated GitHub link so I can review the issue and identify why the picture is not showing.

Ejaz Ali Inayat Ejaz Ali Inayat Topic starter 02/01/2025 11:16 pm

@mohaiminul-islam Sir, I have updated the GitHub Repository but the issue remains the same at line 121 of the home.html file. background: URL property not loading image (bg-image1.jpg) from static>extra-images folder?

Share: