mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-08 06:14:47 +03:00
fix wrong position of CursorPagination if ordering filed is a BooleanField
This commit is contained in:
parent
909a3e80a1
commit
c5e4bb611c
|
@ -678,6 +678,11 @@ class CursorPagination(BasePagination):
|
||||||
|
|
||||||
def _get_position_from_instance(self, instance, ordering):
|
def _get_position_from_instance(self, instance, ordering):
|
||||||
attr = getattr(instance, ordering[0].lstrip('-'))
|
attr = getattr(instance, ordering[0].lstrip('-'))
|
||||||
|
# if ordering is a BooleanField, which mean attr is True/False,
|
||||||
|
# six.text_type(attr) will return u'True'/u'False'. And this will result
|
||||||
|
# wrong filter in paginate_queryset()
|
||||||
|
if isinstance(attr, bool):
|
||||||
|
return '1' if attr else '0'
|
||||||
return six.text_type(attr)
|
return six.text_type(attr)
|
||||||
|
|
||||||
def get_paginated_response(self, data):
|
def get_paginated_response(self, data):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user