I am trying to pass a matplotlib graph in Django template. in views.py file using analyze function, I have created a graph. Then i have passed this graph to my Django template. But nothing shows up in my Django template except [<matplotlib.lines.Line2D object at 0x000001E39AB94F98>]. How can i fix this?
my views.py
from django.shortcuts import render,redirect
from django.contrib.auth import login,authenticate,logout
from diabetes.forms import UserSignupForm,UserLoginForm,MeasurementsForm
from diabetes.models import Measurements
import pandas as pd
import matplotlib.pyplot as plt
def analyze(request):
qs=Measurements.objects.all().values()
data=pd.DataFrame(qs)
img=plt.plot(data.loc[:,'created'],data.loc[:,'d_value'])
return render(request,'diabetes/analyze.html',{'df':img})