I am working with plugin datatable and django.
I have url to view ajax_table in urls.py:
url(r'^someurl/$', 'someapp.views.ajax_table', name='ajax_table'),
This way I can call function ajax_table from my datatable.
var datatable = $("#my_table").dataTable({
"bJQueryUI" : true,
"bProcessing":true,
"bServerSide": true,
"sAjaxSource": "{% url ajax_table %}",
"sPaginationType": "custompagination"
};
It is working properly.
But when I try to send some params from client to server code:
"sAjaxSource": "{% url ajax_table %}?param=some_number"
I can not get this param on server side (‘no param’ printed):
def ajax_table(request):
print 'param: %s' % request.GET.get('param','no param')
How can I send param to server properly?
This isn’t a django problem (you’re doing the right thing here as far as django is concerned), it’s a datatables issue. You can’t add params directly to the
sAjaxSourceparameter, you have to do it with the datatables API.The following documentation describes how to send extra data to the server in the form of parameters.