diff --git a/app/grants/views.py b/app/grants/views.py index 252ed0a916b..10f2f71d7c7 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -38,6 +38,7 @@ from django.core.paginator import EmptyPage, Paginator from django.db import connection, transaction from django.db.models import Q, Subquery +from django.db.models.functions import Lower from django.http import Http404, HttpResponse, JsonResponse from django.http.response import HttpResponseBadRequest, HttpResponseServerError from django.shortcuts import get_object_or_404, redirect @@ -760,6 +761,9 @@ def get_grants_by_filters( field_name = f'clr_prediction_curve__{sort_by_index}__2' _grants = _grants.order_by(f"{order}{field_name}") + elif '-sort' in sort: + _grants = _grants.order_by(Lower(f"{sort}")) + # elif 'random_shuffle' in sort: # _grants = _grants.order_by('?') @@ -769,7 +773,7 @@ def get_grants_by_filters( _grants = _grants.filter(is_clr_active=True).order_by(f"{sort}") elif sort.replace('-', '') in [ - 'weighted_shuffle', 'metadata__upcoming', 'metadata__gem', 'created_on', 'amount_received', 'contribution_count', 'contributor_count', 'last_update', 'title' + 'weighted_shuffle', 'metadata__upcoming', 'metadata__gem', 'created_on', 'amount_received', 'contribution_count', 'contributor_count', 'last_update' ]: print(f"Sort is {sort}") _grants = _grants.order_by(f"{sort}")