Hi,
     Try this.
     style="background: url(../images/showcase.jpg) no-repeat top center
!important;"
    Add these in your settings.py file.
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

  STATIC_URL = '/static/'

  STATICFILES_DIRS = [
     os.path.join(BASE_DIR, 'static')
  ]

   MEDIA_URL = '/images/'

    MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')
     Also check the correct path of images. Whether the images are loading
properly by pasting the image path url in the browser.
     All the best.



On Tue, Aug 25, 2020 at 5:46 AM MAMADOU KANTE <bkatc...@gmail.com> wrote:

> I did load static at the top of the file {% load static %}.
> Also I linked the CSS file named style.css. Part of the css file was
> working perfectly. I only had issues with the background image.
>
> On Mon, Aug 24, 2020 at 4:02 PM sapna Choudhary <csa...@gmail.com> wrote:
>
>> create a directory named 'static' in the current directory. This
>> directory is used to store images/css files, you can load static in
>> template using {%load static%}  this code block and link under image tag
>> like this {% static 'app_name/img.jpg' %}
>>
>> On Mon, Aug 24, 2020 at 6:16 PM 'Akash Sinha' via Django users <
>> django-users@googlegroups.com> wrote:
>>
>>>
>>> Hi
>>>
>>> Create a folder inside ur project as static and keep ur images,css and
>>> js files into that folder then in your settings.py file define static path.
>>> U need to run python manage.py collect static command on terminal and then
>>> you have to link that css file in HTML
>>>
>>>
>>> Hint: check for Managing static files in official django doc or try
>>> stack overflow.com you will get example to setup static path
>>>
>>>
>>> On Mon, 24 Aug 2020 at 5:37 pm, MAMADOU KANTE
>>> <bkatc...@gmail.com> wrote:
>>> Hi Everybody!
>>> I am trying to set a background image using the STYLE tag with django
>>> template as follows:
>>>  <div class="background-img-wrapper" style="
>>> background-image: url(images/background1.jpg)"></div>
>>> But when I open the HTML page and inspect the page I receive an image
>>> with width zero. Can anyone help?
>>> When I use the same syntax on a regular HTML without django templates it
>>> works.
>>>
>>> On Mon, Aug 3, 2020 at 10:02 AM Obodoma Uzondu Vincent <
>>> uobodoma...@gmail.com> wrote:
>>>
>>> Hello your have to follow the direction where you stored your file .
>>> Generally, in Django you create a static folder then maybe an image files
>>> where you store the images. You should link the image this way src= "{%
>>> static 'images/imag.png' %}"
>>>
>>> On Mon, 3 Aug 2020, 10:06 Yemin Sajid, <yeminsa...@gmail.com> wrote:
>>>
>>> This may not work as intended if the CSS files are not rendered using
>>> the Django template engine. You have to put the style declaration where
>>> you'd need the image in the *<style></style>* tag in your template
>>> code. From there you can use the *{% static “images/imag.png” %}*
>>> syntax.
>>> On Friday, July 31, 2020 at 5:58:48 PM UTC+6 Chander shekhar wrote:
>>>
>>> tried this buddy yet it is not working
>>>
>>> Regards
>>> Chander Shekhar
>>> (bestcsp)
>>>
>>>
>>> On Thu, Jul 30, 2020 at 6:11 PM Irfan Khan <irfa...@gmail.com> wrote:
>>>
>>> {% static 'imag.jpg' %}   instead of this try
>>>
>>> {% static “images/imag.png” %}
>>>
>>> On Thu, 30 Jul 2020 at 6:07 PM, Chander shekhar <best...@gmail.com>
>>> wrote:
>>>
>>> I am unable to fetch images from css file .
>>> I have used {% load static %}
>>> {% static 'imag.jpg' %}
>>> buti can't fetch.console is saying image not found.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/554cbaf1-3b94-40b4-a0f1-efe0bd3f24ceo%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/554cbaf1-3b94-40b4-a0f1-efe0bd3f24ceo%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CALKGVio%3DAsCafgcd-zfjBb2of-RWbPaTwwGjf7sXbjstgFdM6Q%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CALKGVio%3DAsCafgcd-zfjBb2of-RWbPaTwwGjf7sXbjstgFdM6Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/f0e45bd1-68ca-405f-a033-c808d6da53d5n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/f0e45bd1-68ca-405f-a033-c808d6da53d5n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CACsKspkUCWwQdO_nGB%3DoU61X9qta7_8bFoBJODSF5rZNoVhiyQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CACsKspkUCWwQdO_nGB%3DoU61X9qta7_8bFoBJODSF5rZNoVhiyQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAOUY%2BRry8CUXbtx9QGhXYoU5c8R92gxG3q32%2B7dFpiPTnNgWaQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAOUY%2BRry8CUXbtx9QGhXYoU5c8R92gxG3q32%2B7dFpiPTnNgWaQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/1004603577.4391205.1598272002937%40mail.yahoo.com
>>> <https://groups.google.com/d/msgid/django-users/1004603577.4391205.1598272002937%40mail.yahoo.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAP6mExi4WiFhC-ZaFgkAGv_5EQCgJdfbvyOqU4PabQBxm1ThZg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAP6mExi4WiFhC-ZaFgkAGv_5EQCgJdfbvyOqU4PabQBxm1ThZg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAOUY%2BRpFeLzvsK57oNzObXKQwx7kRYgthirF0F0%3DUBkgNuLqYw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAOUY%2BRpFeLzvsK57oNzObXKQwx7kRYgthirF0F0%3DUBkgNuLqYw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thanks and Regards

J. Ranga Bharath
cell: 9110334114

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK5m317iBFh9XxsosDsJ1YaF33pBhP%2BTGJxrQevz0D1p-V44rQ%40mail.gmail.com.

Reply via email to