Failing to set PAGE_SIZE
and using LimitOffsetPagination can raise unexpected error
#3692
Labels
Milestone
PAGE_SIZE
and using LimitOffsetPagination can raise unexpected error
#3692
Specifically,
if
api_settings.PAGE_SIZE
isNone
(default) and one manually callsLimitOffsetPagination.paginate_queryset(...)
followed byLimitOffsetPagination.get_paginated_response(...)
,get_paginated_response
will raise anAttributeError
becauseself.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 requiresself.limit
to not beNone
)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 (affectingget_next/previous_link
methods etc)The text was updated successfully, but these errors were encountered: