Monday, January 31, 2022

Re: how to Display images other than from static folder.

tell me what you want to get as a result? do you want to display multiple images on HTML template?

On Mon, Jan 31, 2022 at 8:27 PM ramsha azhar <ramshaazhar12@gmail.com> wrote:
So guide me the write way ... 

On Mon, 31 Jan 2022, 7:45 pm DJANGO DEVELOPER, <abubakarbryar@gmail.com> wrote:
you are doing it the wrong way. totally the wrong way. I am not being rude.

On Mon, Jan 31, 2022 at 7:42 PM ramsha azhar <ramshaazhar12@gmail.com> wrote:
Gide me Django develpers. I just want to display my pictures that are created each time new.
My mages are created in my project folder, not in the static folder.
how I display images on the HTML page by using the path of my project folder.

views.py

def Image_display(request):
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  filename = 'Tree.jpg'
  filepath = BASE_DIR + '//' + filename
  images = Image.objects.all('filepath')
  return render(request, "xyz.html", {'images': images})

url.py
path('Image_display/', views.Image_display, name="Image_display"),

HTML page
<img src="/Image_display/" alt="" class="img">
<img src="/Image_display/" alt="" class="img">
<img src="/Image_display/" alt="" class="img">
<img src="/Image_display/" alt="" class="img">

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8da245ea-ea90-4730-83c0-accafc93b86bn%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKPY9p%3DE1FmUc%3Dqqy1tGYBJbimFX873XXSTDndnn4kVUjo3ZWg%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMyb2%3DheLgJo5dMxsCgQ8cm%3Dp0px5EHpLr2frYtDowV8mmC%2BbQ%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKPY9p%3DOofwq7YrTp%3DWoKyO7mgxVovK2wN3-%3Dm9Ed2zTWZ%2BdAg%40mail.gmail.com.

No comments:

Post a Comment