Stuck in processing when next button is pushed (server-side processing)

Stuck in processing when next button is pushed (server-side processing)

geantbrungeantbrun Posts: 2Questions: 1Answers: 0
edited March 2015 in Free community support

Hi,
I'm pretty new to Datatables and I try to use it via django-datatables-view python package (1.6). I have a filter view that returns the http response rendered by my filter html file (code at the bottom). Everything works fine for the first 25 entries. The GET request is:

GET /entites/list_json/?sEcho=1&iColumns=5&sColumns=&iDisplayStart=0&iDisplayLength=25&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&mDataProp_4=4&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&iSortCol_0=2&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=false&_=1426615055578

The problem is when I push the next button, the page stucks on "processing". It seems to be related to the iDisplayStart parameter which is the only one that change from the above request:

GET /entites/list_json/?sEcho=1&iColumns=5&sColumns=&iDisplayStart=25&iDisplayLength=25&mDataProp_0=0&mDataProp_1=1&mDataProp_2=2&mDataProp_3=3&mDataProp_4=4&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&iSortCol_0=2&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=false&_=1426615055578

This request, when invoked directly in my browser, has the following result:

{"text": "not enough arguments for format stringnot enough arguments for format string", "result": "error"}

If I manually change in this request the iDisplayStart (substituting 25 for 0), the json is again valid and the result is:

{"result": "ok", "iTotalRecords": 65148, "aaData": [[...]], , "sEcho": 2, "iTotalDisplayRecords": 65148}

My filter view:

def filter_view(request):
    form = EntiteFilterForm(request.user)
    data = reverse('entite_list_json')
    # some other code ...
    return(render_to_response(
        'entites/entite_filter.html',
        {'form': form, 'data': data},
        context_instance=RequestContext(request),
    ))

js:

$(document).ready(function() {
    var oTable = $('#entite_table').dataTable( {
        "sDom": 'T<"clear">lrtip',
        "oTableTools": {
            "sSwfPath": "{{ STATIC_URL }}datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
            "aButtons": [ "csv", "pdf", "print" ]
        },
        "aLengthMenu": [
            [10, 25, 50, 100, 200, 300],
            [10, 25, 50, 100, 200, 300],
        ],
        "iDisplayLength": 25,
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "{{ data }}",
        "aaSorting": [ [2,'asc']],
        // Disable sorting for the Actions column.
        "aoColumnDefs": [ { "bSortable": false, "aTargets": [ 4 ] } ]
    });

Interestingly, when I run the web server with the sqlite engine, the buttons are working like a charm. The problem seems to appear only when I use my SQL Server via the django-pyodbc engine.

Any help would be greatly appreciated,
Patrick

Answers

  • geantbrungeantbrun Posts: 2Questions: 1Answers: 0
    edited March 2015

    It appears that the bug is in django_pyodbc. I changed the code, line 340 of file django_pyodbc/compiler.py. Where it reads :

    parens[key] = buf% parens
    

    I substituted the line for:

    if parens:
      parens[key] = buf% parens
    else
      parens[key] = buf
    

    and it works.

This discussion has been closed.