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 <
[email protected]> 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
> <[email protected]> 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 <
> [email protected]> 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, <[email protected]> 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 <[email protected]> wrote:
>
> {% static 'imag.jpg' %}   instead of this try
>
> {% static “images/imag.png” %}
>
> On Thu, 30 Jul 2020 at 6:07 PM, Chander shekhar <[email protected]> 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 [email protected].
> 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 [email protected].
>
> 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 [email protected].
> 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 [email protected].
> 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 [email protected].
> 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 [email protected].
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP6mExi4WiFhC-ZaFgkAGv_5EQCgJdfbvyOqU4PabQBxm1ThZg%40mail.gmail.com.

Reply via email to