Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Pagination - displaying page numbers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stephen  
View profile  
 More options Mar 23 2006, 11:49 am
From: "Stephen" <stevie...@gmail.com>
Date: Thu, 23 Mar 2006 08:49:07 -0800
Local: Thurs, Mar 23 2006 11:49 am
Subject: Pagination - displaying page numbers
Hello,

I've just started looking at Django, it's certainly looking like a very
good choice for the sort of projects I'll be doing in the near future.

Just now I've been looking at pagination and have a question:

I'm using the generic view "list_detail" to view a list of results.  I
want to use pagination to restrict the number of items on a page.  To
do this I've added a "paginate_by" value to the info_dict dictionary in
my urls.py file.  This results in my results being paginated correctly,
and the additional context parameters are available in my template.  I
can use these to show how many hits there were and how many pages of
results etc there are.  My problem comes with trying to show a numbered
link to each page of results (like google does at the bottom of its
results page).  I thought this would be straightforward - just do a
loop - but as far as I can see the {% for %} tag can only iterate over
an array, and the "pages" context property is a number.  What is the
right way to go about looping from N to N+M in a template ?  My feeling
is that looping over a list is the nicest way, but then I can't get the
pagination to work like I want!  Apologies if I'm missing something
really obvious!

In the course of trying to figure this out I tinkered around with the
list_detail.py file and tried adding extra context parameters (e.g.
'page_list':range(1, pages+1, 1) ).  These never showed up in my
templates though - are there specific steps to take in order to make
changes to the django source files be noticed by the server (I'm using
the test server that comes with Django)?

Thanks in advance for any help,

Stephen.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen  
View profile  
 More options Mar 23 2006, 12:11 pm
From: "Stephen" <stevie...@gmail.com>
Date: Thu, 23 Mar 2006 09:11:06 -0800
Local: Thurs, Mar 23 2006 12:11 pm
Subject: Re: Pagination - displaying page numbers
The answer to the second part of my question *was* very obvious... I
was editing the wrong copy of the source file.  I needed to change the
copy installed under my Python directory, not the one in the Django
directory.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
limodou  
View profile  
 More options Mar 23 2006, 7:45 pm
From: limodou <limo...@gmail.com>
Date: Fri, 24 Mar 2006 08:45:27 +0800
Local: Thurs, Mar 23 2006 7:45 pm
Subject: Re: Pagination - displaying page numbers
On 3/24/06, Stephen <stevie...@gmail.com> wrote:

One way I think is just like what you do: create a extra_context.

The other way is create a custom tag to create a list. Someone has
submit this patch before. http://code.djangoproject.com/ticket/1162

Or you can use a custom tag written by me to calculate the list in
template: expr tag

http://groups.google.com/group/django-users/browse_thread/thread/6c1c...

{% expr range(pages) as page_number %}
{% for i in page_number %}
...
{% endfor %}
--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »