1👍
✅
Try this:
def histogram_plot(request):
context={}
df = pd.read_csv(test_file) #Read using pandas
hist_list = []
for column in df.columns:
fig=plt.figure()
plt.hist(df[column])
histogram=mpld3.fig_to_html(fig)
hist_list.append([histogram])
context["hist_list"] = hist_list
return render(request,"base.html",context)
{% for histogram in hist_list %}
{% for elem in histogram %}
{{ elem|safe }}
{% endfor %}
{% endfor %}
This simply appends all your histograms to a list and then loops over them in your template.
Source:stackexchange.com