From 758bb25a09636dcb5a94d22863ddfb379de14851 Mon Sep 17 00:00:00 2001 From: Richard Blechinger <hello@pretzelhands.com> Date: Fri, 19 Nov 2021 10:36:49 +0100 Subject: [PATCH] Strip - character to make sure field can be validated properly --- program/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/views.py b/program/views.py index 15655307..6c19c532 100644 --- a/program/views.py +++ b/program/views.py @@ -541,7 +541,7 @@ class APITimeSlotViewSet(viewsets.ModelViewSet): # If someone tries to sort by a field that isn't available on the model # we silently ignore that and use the default sort order. model_fields = [field.name for field in TimeSlot._meta.get_fields()] - if order not in model_fields: + if order.lstrip('-') not in model_fields: order = default_order -- GitLab