myarik / django-rest-elasticsearch

Elasticsearch support for Django REST Framework
Other
192 stars 38 forks source link

Pagination controls are not shown in browsable API #37

Open aleehedl opened 6 years ago

aleehedl commented 6 years ago

Hi,

Normally Django Rest Framework displays the pagination controls in the browsable API by default. With django-rest-elasticsearch's ListElasticAPIView they are not visible, even if the corresponding fields (previous, next, count) are present in the response data. This happens because the paginator is not added to the response context.

When building the context, DRF looks for the attribute paginator in the view class: https://github.com/encode/django-rest-framework/blob/master/rest_framework/renderers.py#L675

With django-rest-elasticsearch's ListElasticMixin the paginator property is named es_paginator and this is not added to the context of the response. By renaming the property to paginator the pagination controls seem to appear.