hi ,

here is my view for getting image :
I am using a stringIO buffer for temporary storage of the image file and 
then rendering it to the html .


def my_image(request):
    from matplotlib import pyplot as plt        
    buffer = cStringIO.StringIO()
    width = 0.5
    males = int(Mice.objects.filter(gender = 'M').count())
    females = int(Mice.objects.filter(gender = 'F').count())
    fig = plt.figure()
    ax = fig.add_subplot(111)
    rects1 = ax.bar(0, males, width, color='r')
    rects2 = ax.bar(width,females,width,color='y')
    ax.set_ylabel('Scores')
    ax.set_title('Scores by group and gender')
    ax.set_ylabel('Scores')
    ax.set_title('Scores by group and gender')
    ax.set_xticks([0.25 ,0.75])
    ax.set_xticklabels(('M','F'))
    ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
    fig.savefig(buffer , format='png')
    response = HttpResponse(mimetype='image/png')
    response.write(buffer.getvalue())
    return render(request,'search_results.html',{'response':response},)


What should my template have to get the image ??

please help me with this .

thanks

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to