# Embedding plotly graph on djgano template

**URL:** <https://community.plotly.com/t/embedding-plotly-graph-on-djgano-template/1960>\
**Category:** Plotly Fundamentals\
**Created:** [August 24, 2016, 9:56am UTC](https://community.plotly.com/t/embedding-plotly-graph-on-djgano-template/1960 "2016-08-24T09:56:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hkhr](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/hkhr/32/520_2.png) [@hkhr](https://community.plotly.com/u/hkhr)\
**Post date:** [August 24, 2016, 9:56am UTC](https://community.plotly.com/t/embedding-plotly-graph-on-djgano-template/1960/1 "2016-08-24T09:56:30Z")

</div>

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](http://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 %}
```
