Here is a minimal but elegant solution using Django_Pandas and an extended Bootstrap table ( https://github.com/wenzhixin/bootstrap-table )
The finesse comes from the ability to export the Pandas DataFrame to JSON, and for the Bootstrap script, to use this JSON content.
The HTML table is written for us, we donβt need to worry about it (see below, where we simply include the "table" tag without writing the lines themselves or even the for loop.) And this is interactive. And Bootstrap makes it beautiful.
: Bootstrap, jQuery, Django_Pandas, wenzhixin / bootstrap-table
models.py
from django.db import models from django_pandas.managers import DataFrameManager class Product(models.Model): product_name=models.TextField() objects = models.Manager() pdobjects = DataFrameManager()
views.py
from models import Product def ProductView(request): qs = Product.pdobjects.all()
product.html
<script src='/path/to/bootstrap.js'> <script src='/path/to/jquery.js'> <script src='/path/to/bootstrap-table.js'> <script src='/path/to/pandas_bootstrap_table.js'> <table id='datatable'></table>
pandas_bootstrap_table.js
$(function() { $('#datatable')({ striped: true, pagination: true, showColumns: true, showToggle: true, showExport: true, sortable: true, paginationVAlign: 'both', pageSize: 25, pageList: [10, 25, 50, 100, 'ALL'], columns: {{ columns|safe }},