mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 01:20:02 +03:00
Fix sorting by related fields
Allow sorting by `related_field__field_name` using django notation with `__` as separator.
This commit is contained in:
parent
5b990d4092
commit
43f91f5a09
|
@ -873,7 +873,9 @@ class CursorPagination(BasePagination):
|
|||
if isinstance(instance, dict):
|
||||
attr = instance[field_name]
|
||||
else:
|
||||
attr = getattr(instance, field_name)
|
||||
attr = instance
|
||||
for field in field_name.split('__'):
|
||||
attr = getattr(attr, field)
|
||||
return str(attr)
|
||||
|
||||
def get_paginated_response(self, data):
|
||||
|
|
Loading…
Reference in New Issue
Block a user