mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-30 18:09:59 +03:00
CursorPagination doesn't support nested field orderding
_get_position_from_instance couldn't find nested field model for example user__post__created_at
This commit is contained in:
parent
9d06e43d05
commit
02b2e99df4
|
@ -772,7 +772,13 @@ class CursorPagination(BasePagination):
|
||||||
if isinstance(instance, dict):
|
if isinstance(instance, dict):
|
||||||
attr = instance[field_name]
|
attr = instance[field_name]
|
||||||
else:
|
else:
|
||||||
attr = getattr(instance, field_name)
|
if '__' in field_name:
|
||||||
|
field_names_nested = field_name.split('__')
|
||||||
|
attr = instance
|
||||||
|
for field in field_names_nested:
|
||||||
|
attr = getattr(attr, field)
|
||||||
|
else:
|
||||||
|
attr = getattr(instance, field_name)
|
||||||
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