Skip to content

Commit cadee24

Browse files
committed
Merge branch 'master' of github.com:altschool/dynamic-rest
2 parents aadb490 + 1fc59dd commit cadee24

14 files changed

+29
-17
lines changed

dynamic_rest/datastructures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""This module contains custom data-structures."""
2-
from django.utils import six
2+
import six
33

44

55
class TreeMap(dict):

dynamic_rest/fields/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import importlib
44
import pickle
55

6-
from django.utils import six
6+
import six
77
from django.utils.functional import cached_property
88
from rest_framework import fields
99
from rest_framework.exceptions import ValidationError, ParseError

dynamic_rest/filters.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.core.exceptions import ValidationError as InternalValidationError
44
from django.core.exceptions import ImproperlyConfigured
55
from django.db.models import Q, Prefetch, Manager
6-
from django.utils import six
6+
import six
77
from rest_framework import serializers
88
from rest_framework.exceptions import ValidationError
99
from rest_framework.fields import BooleanField, NullBooleanField
@@ -667,8 +667,11 @@ def filter_queryset(self, request, queryset, view):
667667

668668
ordering = self.get_ordering(request, queryset, view)
669669
if ordering:
670-
return queryset.order_by(*ordering)
671-
670+
queryset = queryset.order_by(*ordering)
671+
if any(['__' in o for o in ordering]):
672+
# add distinct() to remove duplicates
673+
# in case of order-by-related
674+
queryset = queryset.distinct()
672675
return queryset
673676

674677
def get_ordering(self, request, queryset, view):

dynamic_rest/links.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""This module contains utilities to support API links."""
2-
from django.utils import six
3-
2+
import six
43
from dynamic_rest.conf import settings
54
from dynamic_rest.routers import DynamicRouter
65

dynamic_rest/processors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""This module contains response processors."""
22
from collections import defaultdict
33

4-
from django.utils import six
4+
import six
55
from rest_framework.serializers import ListSerializer
66
from rest_framework.utils.serializer_helpers import ReturnDict
77

dynamic_rest/routers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
except ImportError:
99
from django.core.urlresolvers import get_script_prefix
1010

11-
from django.utils import six
11+
import six
1212

1313
import rest_framework
1414
from rest_framework import views

dynamic_rest/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import inflection
77
from django.db import models
8-
from django.utils import six
8+
import six
99
from django.utils.functional import cached_property
1010
from rest_framework import __version__ as drf_version
1111
from rest_framework import exceptions, fields, serializers

dynamic_rest/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.utils.six import string_types
1+
from six import string_types
22

33
FALSEY_STRINGS = (
44
'0',

dynamic_rest/viewsets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""This module contains custom viewset classes."""
22
from django.core.exceptions import ObjectDoesNotExist
33
from django.http import QueryDict
4-
from django.utils import six
4+
import six
55
from django.db import transaction, IntegrityError
66
from rest_framework import exceptions, status, viewsets
77
from rest_framework.exceptions import ValidationError

install_requires.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Django>=1.11,<3.0.0
1+
Django>=1.11,<3.1.2
22
djangorestframework>=3.8.0,<3.12.0
3-
inflection>=0.3.1
3+
inflection>=0.4.0
44
requests

0 commit comments

Comments
 (0)