Inheriting from this question which wasn't completed to a workable code solution from what I can tell.
I'm trying to get a very simple wenzhixin/bootstrap-table to work. I can print the columns and data objects to the console - so they work. Here are the code snippets:
#variables
qs = a django queryset
df = a pandas dataframe
#views.py
class MyView(generic.ListView):
# some stuff to get qs = queryset
df = read_frame(qs)
json = df.to_json()
columns = [{'field':f, 'title': f} for f in MyModel._meta.fields]
context = {
'columns': columns,
'data': json,}
return context
#MyView.html
<script src='/path/to/bootstrap-table.js'>
<script src='/path/to/pandas_bootstrap_table.js'>
<script src='/path/to/bootstrap-table.css'>
<script src='/path/to/pandas_bootstrap_table.js'>
<script src='/path/to/bootstrap.min.cs
<script src='/path/to/jquery-3.3.1.slim.min.js
<script src='/path/to/popper.min.js
<script src='/path/to/bootstrap.min.js
<script src='/path/to/jquery.min.js
<table id='datatable'></table>
There are other elements in the view using bootstrap - everything else works - just the last line where it has a table with id='datatable' isn't rendering.
The pandas_bootstrap_table.js is where I've spent my most time trying to get the function to call. I believe this is where the problem is.
#pandas_bootstrap_table.js
$(function() {
$('#datatable').bootstrapTable({
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 }},
data: {{ data|safe }},
});
});
I'm using VSCode for the editing and it is throwing errors on the django template tag references within the js file - but it either isn't hitting the js file or there isn't really an error (linting?)
In the above referenced SO post the answer is market accepted, but the comments below indicate that it required some additional modifications to the js file - I've tried both.
Any ideas on what I've missed?