From 36119cad31ea8a0d5a248fd0a1929350d291ef92 Mon Sep 17 00:00:00 2001 From: Andrew Tallos Date: Mon, 26 Mar 2018 07:22:45 -0400 Subject: [PATCH] Enable OrderingFilter to handle an empty tuple (or list) for the 'ordering' field. (#5899) --- rest_framework/filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index 830d0a616..cf8f6d1f7 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -242,7 +242,7 @@ class OrderingFilter(BaseFilterBackend): def get_template_context(self, request, queryset, view): current = self.get_ordering(request, queryset, view) - current = None if current is None else current[0] + current = None if not current else current[0] options = [] context = { 'request': request,