any suggestions?? hehehe

On Sat, Aug 23, 2008 at 7:35 PM, Juan Hernandez <[EMAIL PROTECTED]>wrote:

> I have this very simple and primitive pagination method being called with
> this instruction in urls.py
>
> ###
> (r'^pyisp/menu/(\d+)/$', 'mail.views.menuPaginator'),
> ###
>
> This is the method
>
> ###
> def menuPaginator(request, number):
>
>     domains = g.objects.all()
>     paginator = ObjectPaginator(domains, 10)
>     pages = str(paginator.pages)
>     lista = paginator.get_page(number)
>
>     #define whether there is a previous or a next page
>
>     if paginator.has_next_page(int(number)) == True:
>         numberRes = str(int(number) + 1)
>         next = "<a href=../" + numberRes + "> >> </a>"
>     else:
>         next = '>>'
>
>     if paginator.has_previous_page(int(number)) == True:
>         numberRes = str(int(number) - 1)
>         previous = "<a href=../" + numberRes + "> << </a>"
>     else:
>         previous = '<<'
>
>     return render_to_response('basic.html',{
>             'titleWeb': 'PyISP Menu',
>             'titleH1': 'Domains',
>             'submitValue': "'Search'",
>             'pages': "Has " + pages + " pages",
>             'lista': lista,
>             'previous': previous,
>             'next': next,
>
>             })
> ###
>
> 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??
>
> thank you very much for your help
> jhv
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to