I am working on a django application. In the application I am trying to display a pandas dataframe in a django template. I am loading a csv file as follows.
df = pd.read_csv(os.path.join(path, str(request.FILES['file'])))
table_content = df.to_html()
context = {'table_content': table_content}
return render(request, 'index.html', context)
The problem I am facing is when I try to display the table. In the template I am retrieving the dataframe as {{table_content}}. But this just displays the html code for the table and not the table itself. I can do a HttpResponse to display the table, but then the rest of the content in the template disappears and only the table is displayed.
What am I doing wrong?