Probably I haven't yet understand how the urls.py works...but I don't know how to load the data with "bServerSide" of datatables... I think to have a problem with my urls.py. I use Django, datatables.js and this is my code:
main.html
<table cellpadding="0" cellspacing="0" border="0" id="example1">
<thead>
<tr><th>Name</th></tr>
</thead>
<tbody></tbody>
</table>
<script type="text/javascript" language="javascript" class="init">
$(document).ready(function() {
$('#example1').dataTable( {
"bServerSide": true,
"sAjaxSource": "main.html/getdata_json",
"bProcessing": true,
} );
} );
</script>
views.py
def myajaxview(request):
report = []
start = request.GET['iDisplayStart']
length = request.GET['iDisplayLength']
query = name.objects.all() #or any kind of queryset
query = query[start:start+length]
for q in query:
report.append(json.dumps(q.nome_struttura))
json = json.dumps(report)
return HttpResponse(json, content_type='application/json')
urls.py
urlpatterns = i18n_patterns('',
...
url(r'^getdata_json$', 'views.myajaxview'),
...
I don't know where is the error. Can you help me please?