Skip to content

Commit ca683dd

Browse files
manderjstephane
authored andcommitted
templatetags.common: fix sorting direction with invalid params
sorting by an invalid direction shouldn't fail and use ASC order
1 parent b1d4a16 commit ca683dd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

webstack_django_sorting/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ def render_sort_anchor(request, field_name, title):
1111
sort_by = get_params.get("sort", None)
1212
if sort_by == field_name:
1313
# Render anchor link to next direction
14-
current_direction = SORT_DIRECTIONS[get_params.get("dir", "")]
14+
current_direction = SORT_DIRECTIONS.get(
15+
get_params.get("dir", ""), SORT_DIRECTIONS[""]
16+
)
1517
icon = current_direction["icon"]
1618
next_direction_code = current_direction["next"]
1719
else:

0 commit comments

Comments
 (0)