On Fri, Aug 22, 2008 at 8:05 PM, Juan Hernandez <[EMAIL PROTECTED]>wrote:
> I have this very simple and primitive pagination method being called with > this instruction in urls.py > > [snipped] > Every time I hit something like domain/pyisp/menu/2 it shows the second > page of the QuerySet. Everything works great but my question is, if I'm in > domain/pyisp/menu/2 and then click next to load domain/pyisp/menu/3, would > these instructions : > > domains = g.objects.all() > paginator = ObjectPaginator(domains, 10) > > hit the DB again?? if it does, what would be the best practice in order to > keep everythong in memory to avoid accessing the database everytime I click > next or previous?? > Yes, you're going to hit the DB again each time you retrieve data for a page. There's no way to avoid that. You cannot maintain state across different requests (well, you can with caching, but that doesn't apply here since you are asking about requesting different pages). Using the Pagniator makes it so that when you hit the DB, the retrieved results are limited to those relevant for the page you are displaying. You are not reading the whole table and then tossing away everything except what is on the page your are displaying, you are only reading from the DB what is actually going to be displayed on the requested page. So your hitting the DB for each request is not a problem. Don't worry about it. Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---