-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
Hello,
I am upgrading an old project to use the last current rest_framework version (3.1.1). I have found that I cannot use paginate_by = None anymore if I want to disable pagination for that view. I changed that for pagination_class = None and it works fine for my javascript, but if I try to access the web browsable API I get the following error:
'NoneType' object has no attribute 'display_page_controls'
I think NoneType is for the pagination_class being None. The thing is that if I override the paginate_queryset(self, queryset) method in the view like this, it works again:
def paginate_queryset(self, queryset):
return None
The error is in rest_framework/renderers.py in get_context, line 614 which has the following code:
if hasattr(view, 'paginator') and view.paginator.display_page_controls: # this is line 614
paginator = view.paginator
else:
paginator = None
Paginator is a GenericAPIView property so it will always return True, which will cause the code view.paginator.display_page_controls to be evaluated and fail.
I have corrected the issue by adding an extra condition so that line will look like if hasattr(view, 'paginator') and view.paginator and view.paginator.display_page_controls:
I hope this could help.
Thank you so much for this framework, what a brilliant work! I have used it with angularjs for many many projects and it works like a charm.
Regards,
Javier