you must use load static tag in your templates as follow:
{% load static %}<img src="{% static "my_app/example.jpg" %}" alt="My image">
i hope this solve the problem for more info refer to django official
docs https://docs.djangoproject.com/en/3.0/howto/static-files/
regards
On Sun, Mar 22, 2020 at 7:19 AM Sandip Nath <[email protected]> wrote:
> Sir thank you for your prompt reply. But it isn't clear to me. The images
> of drivers is getting stored in media/driver_photos and cars in
> media/car_photos, when uploaded from admin page. But car.html and
> driver.html both cannot display those images. Error occurring at the img
> src. I have written it as <img src="media/car_photos/{{ image_name.jpg }}
> alt="{{ image_name }}>. Please advice. Thanks in advance.
>
>
> On Sunday, 22 March 2020 00:21:10 UTC+5:30, Sandip Nath wrote:
>>
>> I am developing a car rental app. I have esigned it such a way that the
>> car and driver images will be uploaded from admin page during runtime from
>> media folder. The models.py working fine. Images can be uploaded to the
>> media folder. But the images are not getting diplayed on the car page.
>> Should the img source in car template be changed to the path of the media
>> folder?
>> Please advice.
>>
> --
> 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/864d147b-1694-4397-8824-0dc3a42d01db%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/864d147b-1694-4397-8824-0dc3a42d01db%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/CAD4tFazXFD4Pj_u0J01E1_SRnKLYe7WZjMfDAzvMWdLgGhrv9g%40mail.gmail.com.