Specifically,
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)
Specifically,
if
api_settings.PAGE_SIZEisNone(default) and one manually callsLimitOffsetPagination.paginate_queryset(...)followed byLimitOffsetPagination.get_paginated_response(...),get_paginated_responsewill raise anAttributeErrorbecauseself.countis 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.countcan only be an integer (true only if_get_countis called, which requiresself.limitto not beNone)The simplest "fix" is to
assert hasattr(self, 'count') and self.count is not Noneand emit a better error message that explains the situation, as anything more would need to be more invasive (affectingget_next/previous_linkmethods etc)