You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have reduced the issue to the simplest possible case.
I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Steps to reproduce
# serializers.py
class PostSerializer(serializers.ModelSerializer):
class Meta:
model = Post
fields = 'title', 'content'
# views.py
class PostView(generics.ListCreateAPIView):
serializer_class = PostSerializer
queryset = Post.objects.all()
I did not set the pagination.
but in the API Documentation
Because generics.views has a default value of 'PageNumberPagination'(in api_settings)
so.. Not getattr (view, 'pagination_class', None) value is always false.
From how you've explained this I don't see any issue.
It's picking up the default setting.
Set pagination_class = None on the view/viewset if you want to turn that off for one instance,
or set it to None in the settings to turn it off globally.
Okay, I think I see - misunderstood the problem! 😄
Issue being that pagination is turned off if PAGE_SIZE=None (regardless of the pagination class that's been set)
We still want to fix this in the schema generation rather than just changing the existings settings defaults tho - #4997 isn't the right approach.
Activity
losnuyh commentedon Mar 17, 2017
Not getattr (view, 'pagination_class', None)is a phrase in the get_pagination_fields method of the SchemaGenerator class in schemas.py .lovelydinosaur commentedon Mar 17, 2017
From how you've explained this I don't see any issue.
It's picking up the default setting.
Set pagination_class = None on the view/viewset if you want to turn that off for one instance,
or set it to None in the settings to turn it off globally.
losnuyh commentedon Mar 17, 2017
The 'page' parameter has no role in API Documents.
The default value of PAGE_SIZE is already None (rest_framework/settings.py)
I thought it would be better to eliminate the meaningless parameter than to add 'pagination_class = None' for each 'ListView Class'
lovelydinosaur commentedon Mar 17, 2017
Okay, I think I see - misunderstood the problem! 😄
Issue being that pagination is turned off if
PAGE_SIZE=None(regardless of the pagination class that's been set)We still want to fix this in the schema generation rather than just changing the existings settings defaults tho - #4997 isn't the right approach.
losnuyh commentedon Mar 17, 2017
Um .. If you do not adjust the default settings
In 'get_pagination_fields' method, argument 'view' always has 'pagination_class'.
At this time, it seems difficult to check whether 'pageniation_class' is user-specified or default setting.
I will think more.
Thank you for your advice.