Skip to content

Commit c5c0f8a

Browse files
committed
Fix dir should be an empty string on not defined
1 parent 5b77812 commit c5c0f8a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/webstack_django_sorting/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Common to Django tags (sorting_tags) and Jinja2 globals (jinja2_globals)
33
"""
4+
45
from operator import attrgetter
56

67
from django.db.models import F
@@ -11,11 +12,10 @@
1112

1213
def render_sort_anchor(request, field_name, title, default_direction):
1314
get_params = request.GET.copy()
14-
sort_by = get_params.get("sort", None)
15+
sort_by = get_params.get("sort", None)
1516
if sort_by == field_name:
17+
dir = get_params.get("dir", "")
1618

17-
dir = get_params.get("dir")
18-
1919
if dir == "asc":
2020
icon = settings.DEFAULT_SORT_UP
2121
elif dir == "desc":
@@ -26,7 +26,7 @@ def render_sort_anchor(request, field_name, title, default_direction):
2626
# Mapping of direction transitions based on the default sort direction
2727
transition_map = {
2828
"asc": {"asc": "desc", "desc": "", "": "asc"},
29-
"desc": {"desc": "asc", "asc": "", "": "desc"}
29+
"desc": {"desc": "asc", "asc": "", "": "desc"},
3030
}
3131
next_direction_code = transition_map[default_direction].get(dir, "")
3232

0 commit comments

Comments
 (0)