Skip to content
Advertisement

putting a pandas dataframe inside a django template

I want to put a pandas dataframe inside a django template. For instance I want something like this:

JavaScript

What I have tried are these codes. First in my django views.py, this was my function:

JavaScript

The template is:

JavaScript

And, the style.css is:

JavaScript

Apparently, when I check it in my browser the template is loaded with the CSS code correctly but it gives me the following output instead of the table that I want:

JavaScript

I am new to django, so maybe my approach is completely wrong.

Advertisement

Answer

I found the solution by myself. Apparently I should change {table} to {table|safe} in the template file. So, the code looks like this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement