how to include image dynamically

92 views
Skip to first unread message

Suresh_Chilukuri

unread,
Feb 24, 2022, 9:05:59 AM2/24/22
to django...@googlegroups.com
I tried using below method but the image was not displaying

Screenshot (397).png

Kasper Laudrup

unread,
Feb 24, 2022, 9:47:14 AM2/24/22
to django...@googlegroups.com
On 24/02/2022 11.57, Suresh_Chilukuri wrote:
> I tried using below method but the image was not displaying
>

Which "method"?

All you've provided is an image of some parts of some Django template code.

That is in no way enough for anyone to be able to help you.

Describe your problem in detail if you want anyone to have a chance to
help you.

Kind regards,

Kasper Laudrup
OpenPGP_0xE5D9CAC64AAA55EB.asc
OpenPGP_signature

Suresh_Chilukuri

unread,
Feb 24, 2022, 10:45:06 AM2/24/22
to django...@googlegroups.com
I am asking how we can get image from function based views dynamically in template file

Where images are present at static folder
-static 
      - Images
             - image1



--
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/6856b014-060c-59e6-0754-8bfcbe9ce58e%40stacktrace.dk.

Kasper Laudrup

unread,
Feb 24, 2022, 11:21:23 AM2/24/22
to django...@googlegroups.com
On 24/02/2022 16.41, Suresh_Chilukuri wrote:
> I am asking how we can get image from function based views dynamically
> in template file
>

What do you mean by dynamic?

Do you mean passing a list of files from a specific sub directory in the
static folder to the template?

Kind regards,

Kasper Laudrup
OpenPGP_0xE5D9CAC64AAA55EB.asc
OpenPGP_signature

Adeyemi Deji

unread,
Feb 24, 2022, 12:22:07 PM2/24/22
to django...@googlegroups.com
They are two ways to this. But would talk about one, the other is more practical. Takeout the baseUrl variable and the forward slash, then use {{ cmp.img.url }}. This should work and if it doesn't. Look for solutions by googling it. Sure u would find answers to ur question.

--
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.

Adeyemi Deji

unread,
Feb 24, 2022, 12:25:31 PM2/24/22
to django...@googlegroups.com
Make sure u configured the Media_root and Media_url appropriately in the settings.py file
Reply all
Reply to author
Forward
0 new messages