Issue in return of Image variable from django view (numpy array) to template
Question: I am a newbie in python/django/web development.

I am facing an issue with returning my image from my `django view` to my
`django template`.

I have a dummy button on my HTML page which calls a function in my `views.py`.
This function returns an image (which is in the form of a numpy array). I want
to return the image to my template. Although, I am able to return the image
variable without any error, in the template I am not being able to see the
image.

This is the code in my `views.py` function which returns the image to the
`dummy.html` page

    
    
    def ipdtest(request, frameslug):
     import cv2
     frame= VTryON.objects.get(slug=frameslug)
     image_of_frame=frame.image.url
     frame_path=("path name"+str(image_of_frame))
     d=Frame_Superimposition()
     img=Frame_Superimposition.frameSuperimpose(d,frame_path)
     #print type(d)
     print type(img)
     #cv2.imshow('img', img)
     #cv2.waitKey(0)
     context={'d':d, 'img':img}
     return render_to_response('dummy.html',  context,context_instance=RequestContext(request))
    

The `img` variable is of the type `numpy array`. I know that the image is
properly being processed since I am able to see it doing a `cv2.imshow`.

So is this a compatibility issue between numpy form and RGB form? If so, then
how do I make the image display properly on to the `dummy.html`? This is how I
retrieve it in my dummy.html page.

    
    
    <body class="body">
    <div id="pageContainer">        
        <br>
          <img src="{{img}}" width=250 height=100/>
        <br>        
    </div>
    

Please give some suggestions on how to solve this. Thanks in advance :)


Answer: What does `print img` statement print...? Anyways try this...

`{{ img.url }}`

