Skip to content

Add min_date and max_date to DatePaginator #9

@joshuadavidthomas

Description

@joshuadavidthomas

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions