i have been trying to embed plotly onto my dgango template but i am unable to get it done, tied many times but i can’t get it done
model.py file
class Preprocess():
df = pd.read_csv('F:\lcdata.csv')
df_sample = df.head()
table = FF.create_table(df_sample)
global table
global df_sample
def import_display(self):
return df_sample
#return iplot(table, filename='pandas_table')
def draw_chart(self):
plotly_url = plot(table, filename='pandas_table')
pie_url = '<iframe width="200" height="200" frameborder="0" seamless="seamless" scrolling="yes" src='+plotly_url+'.embed?width=200&height=200&link=false&showlegend=false></iframe>'
return pie_url
this is my view.py file
…
def display_table(request):
preprocess=Preprocess()
return render(request, 'ml/index.html', { 'preprocess':preprocess})
this is my template index.html
{% block title %}
<h2>Latest reviews</h2>
{% endblock %}
{% block content %}
<div class="row">
<div class="col-xs-6 col-lg-4">
<h4> {{ preprocess.import_display }}</h4>
<div style="width:600;height:500">
{{ preprocess.draw_chart }}
</div>
</div>
</div>
{% endblock %}