Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pagination.LimitOffsetPagination.get_html_context fails when count=0 and offset=0 #3303

Closed
Labels
Milestone
@ugurunver

Description

@ugurunver

For 3.2.2

https://github.com/tomchristie/django-rest-framework/blob/1b53e804ee86e5611bb02ced499e1fcc08b6c5f9/rest_framework/pagination.py#L414

In LimitOffsetPagination.get_html_context method, when offset value is zero, current is 1 (bacause _divide_with_ceil function always returns 0 when first param is 0)

current = _divide_with_ceil(self.offset, self.limit) + 1

and when count is zero too (it means there is no object in our data, model etc.),

final = (            _divide_with_ceil(self.count - self.offset, self.limit) +            _divide_with_ceil(self.offset, self.limit)    )

final computed as 0 (zero) because 'self.count - self.offset = self.offset = 0'
And finally,

if current > final:    current = final

current = final = 0 .
Then _get_displayed_page_numbers function raises assertion error on here:
https://github.com/tomchristie/django-rest-framework/blob/1b53e804ee86e5611bb02ced499e1fcc08b6c5f9/rest_framework/pagination.py#L75

assert current >= 1assert final >= current

Am I doing wrong anything or is it just a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp