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

Failing to set PAGE_SIZE and using LimitOffsetPagination can raise unexpected error #3692

kezabelle opened this issue Dec 2, 2015 · 1 comment


Copy link

kezabelle commented Dec 2, 2015

if api_settings.PAGE_SIZE is None (default) and one manually calls LimitOffsetPagination.paginate_queryset(...) followed by LimitOffsetPagination.get_paginated_response(...), get_paginated_response will raise an AttributeError because self.count is never set.

I'm not going to argue the merits of why it's been manually called (because I didn't write the code, only encountered it), but the resulting exception is not useful for debugging the cause, as the rest of the code all assumes self.count can only be an integer (true only if _get_count is called, which requires self.limit to not be None)

The simplest "fix" is to assert hasattr(self, 'count') and self.count is not None and emit a better error message that explains the situation, as anything more would need to be more invasive (affecting get_next/previous_link methods etc)

@tomchristie tomchristie added this to the 3.4.5 Release milestone Aug 10, 2016
@tomchristie tomchristie modified the milestones: 3.4.7 Release, 3.4.8 Release Sep 21, 2016
@tomchristie tomchristie modified the milestones: 3.4.8 Release, 3.5.1 Release Sep 30, 2016
Copy link

tomchristie commented Apr 27, 2017

Closed via #4998.

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

No branches or pull requests

3 participants