Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just <code>from django.core.paginator import Paginator</code> and make a paginator object as <code>p = Paginator(thestuff, 7)</code> in the view for the homepage, <code>p = Paginator(thestuff, 10)</code> everywhere else. Then in either case bind <code>p</code> in the context you use to render the template. <code>p.object_list</code> will be set appropriately in either case (and you appear to say that's the approach you're using, right? I.e., is that what you mean by "Django's object_list"?).</p> <p>Django <a href="http://docs.djangoproject.com/en/1.0/topics/pagination/" rel="noreferrer">docs</a> have excellent details and examples (assuming you're on 1.0 or better). If you can't make it work, can you show us (a simplified version that still fails, of) your template and view code?</p> <p>Edit: problem has now been clearly shown and I think should be solved by subclassing Django's core paginator, as follows:</p> <pre><code>from django.core.paginator import Paginator, Page class MyPaginator(Paginator): def __init__(self, **kw): self.deltafirst = kw.pop('deltafirst', 0) Paginator.__init__(self, **kw) def page(self, number): "Returns a Page object for the given 1-based page number." number = self.validate_number(number) if number == 1: bottom = 0 top = self.per_page - self.deltafirst else: bottom = (number - 1) * self.per_page - self.deltafirst top = bottom + self.per_page if top + self.orphans &gt;= self.count: top = self.count return Page(self.object_list[bottom:top], number, self) </code></pre> <p>Now use MyPaginator exactly as the above text and examples show the usage of Django's own, except, on creating it, use an extra named argument <code>deltafirst=3</code> to make the first page 3 shorter than the normal per-page length (of 10). So you'd be using a single paginator with a nominal length of 10 but a deltafirst of 3 to make the first page 3 shorter than all others.</p> <p>(There may be problems in <code>validate_number</code> but I'm not sure they'd appear -- if they do, then MyPaginator will need to override that method as well).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload