Skip to content
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

Fix pagination in combination with filters #89

Closed
wants to merge 1 commit into from

Conversation

saruniitr
Copy link
Contributor

@saruniitr saruniitr commented Apr 14, 2020

Change description

Both pagination and filters use query parameters to provide variables
to backend. They both individually work ok but the parameters gets
overwritten if used in combination. Eg apply some filters and select
a particular page from the list of results. In this case once a page
is selected then existing query parameters gets overwritten with the
selected page and because of this filters also gets cleared.

The fix is to append the variables instead of overwriting them which
is implemented using custom template tags.

This PR fixes #46

Both pagination and filters use query parameters to provide variables
to backend. They both individually work ok but the parameters gets
overwritten if used in combination. Eg apply some filters and select
a particular page from the list of results. In this case once a page
is selected then existing query parameters gets overwritten with the
selected page and because of this filters also gets cleared.

The fix is to append the variables instead of overwriting them which
is implemented using custom template tags.
@@ -91,3 +91,31 @@ def query_params_has_value(value, param_key, query_params):
@register.simple_tag
def query_params_value_selected(value, param_key, query_params, text='selected'):
return f' {text}' if str(value) in query_params.getlist(param_key) else ''


@register.simple_tag

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these tag functions need some tests.

@mforner13 mforner13 closed this Jul 9, 2020
@mforner13
Copy link
Contributor

Closing this PR as another PR has been merged to fix this issue in another way (#103).

@cgsunkel cgsunkel deleted the bug/filters-pagination-issue branch July 11, 2022 10:47
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.

Paginating through page numbers with filter conditions
3 participants