shinneider / django-admin-inline-paginator

MIT License
127 stars 21 forks source link

Pagination count incorrect #3

Closed JackAtOmenApps closed 3 years ago

JackAtOmenApps commented 3 years ago

Pretty cool package! Noticed one glaring oddity:

I'm using TabularInlinePaginated as follows.

class OrganizationMembershipInLine(TabularInlinePaginated):
    model = OrganizationMembership
    extra = 0
    per_page = 5

There are 21 results, so I would expect 6 pages with 5 forms each. But the result is 5 pages, each (except last page) with 6 results.

Screenshot from 2021-01-04 23-32-08

Similarly, if I change to use per_page = 3, the result is 7 pages, each (except last page) with 4 forms (for the original 21 results mentioned above).

shinneider commented 3 years ago

Hello @OmenApps thanks for the comments and reporting this bug.

but i couldn't reproduce this on my machine. i created 21 entries on database and setted per_page = 5 and all pages is ok. has 5 pages, 4 with 5 entries, and last with 1 entry.

i see in your print, de last entry is empty, apparently is a extra form to create new data. check de extra on your admin class, if this is set to 0

image image

shinneider commented 3 years ago

@OmenApps if i set extra = 1 i get your problem. see

image

image

JackAtOmenApps commented 3 years ago

So strange. I definitely have extra = 0, copied straight from my code base.

I do use grapelli with my admin, and wonder if there could be some sort of conflict.

Either way, it does not affect performance, the numbering just ends up looking a bit odd. This is a great project. I typically have dozens of inlines on one of my models, and this package has made that model so much more maintainable!

shinneider commented 3 years ago

@OmenApps

Apparently is a bug of graphelli and another user request change for work with this lib. see this PR.

I'm starting to develop a solution for this.