Thanks very much Ludovic for the advice. On Oct 31, 2016 9:53 AM, "ludovic coues" <[email protected]> wrote:
> I would use 1 + 2 from your list. > > 3 might work on 1000 record, depending on how much data there is per > record. But if you grow to more than 10,000 record, the page loading > can take minutes. I have experienced that issue with two different > project. > > Django pagination by itself won't give you the infinite scroll you are > expecting. But it should give you an easy interface for slicing the > data from your db. > > An easier way might be class based view. The following exemple create > a view to a list of object, paginated: > > from django.http import JsonResponse > from django.views.generic import ListView > > class ModelListView(ListView): > model = RecordModel > paginate_by = 20 > > It will try to use the template at app/record_model_list.html, the > context will have the keys paginator, page, is_paginated, object_list. > You can override the method render_to_response to return a json > response. > The documentation on ListView is at [1] and there is an exemple for > returning JsonResponse at [2] > > > [1] https://docs.djangoproject.com/en/1.10/topics/class- > based-views/generic-display/ > [2] https://docs.djangoproject.com/en/1.10/topics/class- > based-views/mixins/#more-than-just-html > > > > > 2016-10-31 2:04 GMT+01:00 ADEWALE ADISA <[email protected]>: > > Hello, > > Please I need an advice on the best approach to take on the following > > issues. > > I have a database table consist of about 1000 record. I need to be > > displaying like 20 records at a time on a page such that when the user > > scroll the browser another batches will be append to the browser. > > Below are the 3 ways am aiming to achieve this: > > > > 1. Using django pagination feature. > > > > 2. Everytime records need to be appended to the browser , an ajax call is > > made to the view, then the queryset is slice using appropriate lower and > > upper band. Then the returned record is appended to the browser. > > > > 3. Fetch the whole records from the database and transfer everything to > the > > browser, then JavaScript is now use to slice and be appending as needed. > > > > NOTE: The webpage would work like yahoo.com mobile site. > > Please with approach is the best in term of performance and speed. > > > > Thanks. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at https://groups.google.com/group/django-users. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/django-users/CAMGzuy8cK7ueHGPwuCjbrV- > SdfZwkYYhg7_t7-Dmmt%3D6g787YA%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > Cordialement, Coues Ludovic > +336 148 743 42 > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/CAEuG%2BTaPWphYQAwa9-rPW5VZ93yyA3kL% > 3Dz8JAecdLRMiKdjihA%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy_Tu7mdL4RTvNGWY%3Dm5PL0ttT4wv9QKeMfiLqd43MiaVw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

