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

Add min_date and max_date to DatePaginator #9

Open
joshuadavidthomas opened this issue Jan 24, 2024 · 0 comments
Open

Add min_date and max_date to DatePaginator #9

joshuadavidthomas opened this issue Jan 24, 2024 · 0 comments

Comments

@joshuadavidthomas
Copy link
Member

joshuadavidthomas commented Jan 24, 2024

Similar to #7, it'd be nice if regardless of the order of the object_list, that there was two properties for the min and max date of a paginator.

There's already a bunch of duplicated logic in the paginator methods dealing with this anyway, should be consolidated.

if isinstance(self.object_list, QuerySet): # type: ignore[misc]
first_obj = self.object_list.first()
last_obj = self.object_list.last()
else:
first_obj = self.object_list[0]
last_obj = self.object_list[-1]
first_date = getattr(first_obj, self.date_field)
last_date = getattr(last_obj, self.date_field)

if isinstance(self.object_list, QuerySet): # type: ignore[misc]
first_obj = self.object_list.first()
last_obj = self.object_list.last()
else:
first_obj = self.object_list[0]
last_obj = self.object_list[-1]
first_date = getattr(first_obj, self.date_field)
last_date = getattr(last_obj, self.date_field)

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

No branches or pull requests

1 participant