only 10 records is processed

only 10 records is processed

RobinLIRobinLI Posts: 4Questions: 1Answers: 0

I have a queryset, which have 12 records, but finally it only processed 10.
trace show it was limit to 10 in function paging(), actually I set the "paging" as false.

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • RobinLIRobinLI Posts: 4Questions: 1Answers: 0
    edited August 2016

    I put the code here. It's Python code with Django.

    urls.py:
    url(r'^test_datatable_Json$', views.test_datatable_Json.as_view(), name = 'test_datatable_Json'),
    
    views.py:
    class test_datatable_Json(LoginRequiredMixin, BaseDatatableView):
        columns = ['id', 'test1']
        order_columns = ['id']
        max_display_length = 500
        #columns = ['outputtree__product_id', 'device_id']
    
        def get_initial_queryset(self):
            """
            Filter records to show only entries from the currently logged-in user.
            """
            wset = testabc.objects.all()
            print('the queryset is: ', wset)
            return wset
    

    records in testabc:

    +----+-------+
    | id | test1 |
    +----+-------+
    |  1 | 1     |
    |  2 | 2     |
    |  3 | 3     |
    |  4 | 4     |
    |  5 | 5     |
    |  6 | 6     |
    |  7 | 7     |
    |  8 | 8     |
    |  9 | 9     |
    | 10 | 10    |
    | 11 | 11    |
    | 12 | 12    |
    +----+-------+
    

    when I type the jsonaddress in browser(http://localhost:8000/test_datatable_Json) and get the following result:

    {"recordsFiltered": 12, "recordsTotal": 12, "draw": 0, "result": "ok", "data": [[1, "1"], [2, "2"], [3, "3"], [4, "4"], [5, "5"], [6, "6"], [7, "7"], [8, "8"], [9, "9"], [10, "10"]]}
    

    it's show 12 records, but actually only return 10.
    I trace into the datatable view, the issue is the paging() function return 10.

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • RobinLIRobinLI Posts: 4Questions: 1Answers: 0

    Just found that when I put &length=-1 in the address, it will get all 12 results.
    (http://localhost:8000/measurement/test_datatable_Json?&length=-1)

    Is this a bug? or should put length=-1 there?

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    It sounds and looks like your Python script hasn't implemented server-side processing. Either you need to implement that, or not use server-side processing.

    Allan

  • RobinLIRobinLI Posts: 4Questions: 1Answers: 0

    Sure, it's server side process issue. At server side, installed Django-datatable-view 1.13.0. and my code is based on BaseDatatableView base clase. the issue is in the base class funcction paging().

            if self.pre_camel_case_notation:
                limit = min(int(self._querydict.get('iDisplayLength', 10)), self.max_display_length)
                start = int(self._querydict.get('iDisplayStart', 0))
            else:
                limit = min(int(self._querydict.get('length', 10)), self.max_display_length)
                start = int(self._querydict.get('start', 0))
    

    with my example, it goes to else and set limit to 10. So I put &length=-1 at request to set this limit to -1.
    I dont' know why my 'paging' = false doesn't take effect. for my understanding, it should not go to paging().

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    I'm afraid I'm not familiar with that Django library. You would need to contact the author of that library for assistance with it - I know next to nothing about Python!

    Allan

This discussion has been closed.