pagination - Django: paginating differently on the first page -


At the minute, I am using Django's object_list to handle pagination. If I feel that after listening to my problem, I am happy to go to the proper peninsula ():

On the homepage, I 7 but All other pages want to paginate by 10 .

How would I go about doing this? I can not really get my head around it. The closest I got to work on this is that the result of the result is leaving the whole page, so obviously I do not want this.

I would appreciate any answers if you need any more information then let me know. Thanks a lot.

Which

simply to django.core

Every other place. Then in any case p in the context that you use to render the template. p.object_list will be set appropriately in any case (and you can say that the method you are using, is not it? That is, "Django's object_list" What does that mean?).

There are excellent descriptions and examples in Jenzo (say that you are 1.0 or better). If you can not work it, can you show us (a simplified version that still fails, yours) template and view code?

EDIT: The problem is now clearly shown and I think it should be resolved by the sub-classes of the core pensinator of the DEGENGO, as follows:

  From django.core.paginator import pageator, page class MyPaginator (Paginator): def __init __ (self, ** kw): self.deltafirst = kw.pop ('Delftfurst', 0) pageitator .__ init __ (auto, ** KW) Def page (self, number): "Returns a page object for the given 1-page page number." Number = self.validate_number (number) if number == 1: bottom = 0 top = self.per_page - self.deltafirst and: bottom = (number -1) * self.per_page - self.deltafwith top = bottom + self.per_page If the top + self Afghan & gt; Self.count: top = self.count return page (self.object_list [bottom: top], number, itself)  

Now use MyPaginator in the same way as the above text and example Degono Show yourself the use, on creating it, use an additional named argument deltafirst = 3 normal page per page length (10 of)). So you will use a single pageinator, with a minimum length of 10, but to make a delft of 3, make at least 3 pages compared to 3 others.

( validate_number but I'm not sure they will appear - if they do, MyPaginator must override that method too).


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -