Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Commit

Permalink
drop SIX ussage
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisvain committed Mar 5, 2020
1 parent e2e61d2 commit 3b373ec
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion django_sortable/models.py

This file was deleted.

11 changes: 3 additions & 8 deletions django_sortable/sortable.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import functools
from operator import itemgetter, attrgetter

from django.utils import six


def cmp(a, b):
return (a > b) - (a < b)
Expand All @@ -27,9 +25,9 @@ def set_normalized_fields(self, fields):

field_list = []
for f in fields:
if isinstance(f, six.string_types):
if isinstance(f, str):
field_list.append((f, (f,)))
elif isinstance(f[1], six.string_types):
elif isinstance(f[1], str):
field_list.append((f[0], (f[1],)))
else:
field_list.append(f)
Expand Down Expand Up @@ -68,10 +66,7 @@ def comparer(left, right):
result = cmp(func(left), func(right))
return 0 if not result else polarity * result

if six.PY2:
result = sorted(self.objects, cmp=comparer)
else:
result = sorted(self.objects, key=functools.cmp_to_key(comparer))
result = sorted(self.objects, key=functools.cmp_to_key(comparer))
else:
raise SortableInvalidObjectsException('An object of this type can not be sorted.')

Expand Down
3 changes: 1 addition & 2 deletions django_sortable/templatetags/sortable.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django import template
from django.conf import settings
from django.template import TemplateSyntaxError
from django.utils import six

register = template.Library()

Expand Down Expand Up @@ -129,7 +128,7 @@ def render(self, context):
try:
format_string = self.format_string.resolve(context)
except:
format_string = six.text_type(self.format_string) or None
format_string = str(self.format_string) or None
try:
img_url = self.img_url.resolve(context)
except:
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ The objective of django-sortable is to provide a flexible way to handle sorting

Like pagination in Django, django-sortable works on a variety of data-types. When possible, an `order_by` clause will be added to a QuerySet but django-sortable also handles lists or tuples of dictionaries or objects. Support is also available for building the `ORDER BY` clause of a SQL query.

Updated version of https://github.com/drewyeaton/django-sortable.

modified to be able top use with python 3 and django 2.0 and newer.

##Installation

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
KEYWORDS = 'sorting sortable queryset sql pagination django'

setup(name='django-sortable',
version='0.3.1',
version='0.4.0',
description='Flexible sorting for Django applications',
long_description=LONG_DESCRIPTION,
author='Drew Yeaton',
Expand Down

0 comments on commit 3b373ec

Please sign in to comment.