diff --git a/url_filter/backends/django.py b/url_filter/backends/django.py index 48aa2c3..5f5cedf 100644 --- a/url_filter/backends/django.py +++ b/url_filter/backends/django.py @@ -107,7 +107,8 @@ def filter_by_specs(self, queryset): queryset = queryset.exclude(**{lookup: value}) to_many = self._is_any_to_many() - return queryset.distinct() if to_many and (include or exclude) else queryset + is_distinct = bool(queryset.query.distinct_fields) + return queryset.distinct() if (not is_distinct) and to_many and (include or exclude) else queryset def _is_any_to_many(self): return any( diff --git a/url_filter/validators.py b/url_filter/validators.py index d40d0ca..fa6c5d8 100644 --- a/url_filter/validators.py +++ b/url_filter/validators.py @@ -6,7 +6,7 @@ MinLengthValidator as _MinLengthValidator, ) from django.utils.deconstruct import deconstructible -from django.utils.translation import ungettext_lazy +from django.utils.translation import ngettext_lazy @deconstructible @@ -16,7 +16,7 @@ class MinLengthValidator(_MinLengthValidator): """ code = "min_length" - message = ungettext_lazy( + message = ngettext_lazy( "Ensure this value has at least %(limit_value)d items (it has %(show_value)d).", "Ensure this value has at least %(limit_value)d items (it has %(show_value)d).", "limit_value", @@ -36,7 +36,7 @@ class MaxLengthValidator(_MaxLengthValidator): """ code = "max_length" - message = ungettext_lazy( + message = ngettext_lazy( "Ensure this value has at most %(limit_value)d items (it has %(show_value)d).", "Ensure this value has at most %(limit_value)d items (it has %(show_value)d).", "limit_value",