From 4031a625093e33dd9e55cf5453ff292f5a67a322 Mon Sep 17 00:00:00 2001 From: Thomas Pollet Date: Tue, 2 Jul 2024 20:42:48 +0200 Subject: [PATCH] don't desc sort attributes that have no desc() method --- safrs/jsonapi_formatting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safrs/jsonapi_formatting.py b/safrs/jsonapi_formatting.py index b3c4d1a..9333b23 100755 --- a/safrs/jsonapi_formatting.py +++ b/safrs/jsonapi_formatting.py @@ -65,7 +65,7 @@ def jsonapi_sort(object_query, safrs_object): # with a minus, in which case it MUST be descending. sort_attr = sort_attr[1:] attr = getattr(safrs_object, sort_attr, None) - if attr is not None: + if attr is not None and hasattr(attr, desc): attr = attr.desc() else: attr = getattr(safrs_object, sort_attr, None)