Skip to content

Fix pagination keys in preserved filters querystring #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qdelcourte
Copy link

Hi!

May fix this issue #20

Problem

Changes from the 2nd page onwards are not saved.

Solution

It appears that model change form doesn't contain the action url with pagination key. So when we click on save then Django lose the pagination context and save the wrong formset (default is for page 1).

Inline pagination needs context on each requests:

def get_page_num(self) -> int:
assert self.request is not None
page = self.request.GET.get(self.pagination_key, '1')
if page.isnumeric() and page > '0':
return int(page)
return 1

Django preserves only _changelist_filters :
https://github.com/django/django/blob/f6f0699d01f5840437bfd236c76c797943ef8edc/django/contrib/admin/options.py#L1039-L1055

Discussions

  • I'm not convinced by the use of inline_pagination_keys in ModelAdmin.
  • InlineModelPaginated naming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants