Skip to content

Commit d40acdd

Browse files
committed
Handle Django < 1.8 too (meta.get_all_field_names)
1 parent cde4aac commit d40acdd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

webstack_django_sorting/templatetags/sorting_tags.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@ def need_python_sorting(self, queryset, ordering):
133133

134134
# Python sorting if not a field
135135
field = ordering[1:] if ordering[0] == '-' else ordering
136-
field_names = [f.name for f in queryset.model._meta.get_fields()]
136+
137+
if getattr(queryset.model._meta, 'get_fields', False):
138+
# Django 1.8+
139+
field_names = [f.name for f in queryset.model._meta.get_fields()]
140+
else:
141+
field_names = queryset.model._meta.get_all_field_names()
142+
137143
return field not in field_names
138144

139145
def render(self, context):

0 commit comments

Comments
 (0)