I can't figure out how to render an editable table using Django-datatable-view
. I want to create a table exactly like this: http://django-datatable-view.appspot.com/x-editable-columns/ from model City
for example.
I've read the docs and tutorials but still can't figure out how to create the table.
This is what I've done so far:
{% extends "base.html" %}
{% block head %}
{% load static %}e
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css">
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>
<script src="{% static "datatable/js/datatableview.min.js" %}"></script>
<script>
datatableview.auto_initialize = false;
$(function () {
var xeditable_options = {};
datatableview.initialize($('.datatable'), {
fnRowCallback: datatableview.make_xeditable(xeditable_options),
});
})
</script>
{% endblock %}
{% block content %}
{{ datatable }}
{{ object_list }}
{% endblock %}
And my view is:
class ZeroConfigurationDatatableView(dtv_views.XEditableDatatableView):
model = dolava_models.City
datatable_options = {
'columns': [
'id',
("Name", 'name', dtv_helpers.make_xeditable),
("Country", 'country', dtv_helpers.make_xeditable),
]
}
Unfortunately my code renders this: