From 474e314357691bdc3578f358b4ccd78483b38c81 Mon Sep 17 00:00:00 2001 From: Simone Pellizzari Date: Thu, 6 Dec 2018 14:46:35 +0100 Subject: [PATCH 1/2] Do not apply distinct if no regular filters have been found. --- url_filter/backends/django.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/url_filter/backends/django.py b/url_filter/backends/django.py index cf6bee1..6a78a2f 100644 --- a/url_filter/backends/django.py +++ b/url_filter/backends/django.py @@ -113,7 +113,7 @@ def filter_by_specs(self, queryset): queryset = queryset.exclude(**{lookup: value}) to_many = self._is_any_to_many() - return queryset.distinct() if to_many else queryset + return queryset.distinct() if to_many and (include or exclude) else queryset def _is_any_to_many(self): return any(self._is_to_many(self.model, i.components) for i in self.regular_specs) From 7cec865b543fbe9d634e418d404d96a621d58873 Mon Sep 17 00:00:00 2001 From: Miroslav Shubernetskiy Date: Thu, 6 Dec 2018 13:07:52 -0500 Subject: [PATCH 2/2] added Simone Pellizzari to authors --- AUTHORS.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 34d2059..9cc1e2c 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -14,4 +14,4 @@ Contributors * Håken Lid - https://github.com/haakenlid * Ryan O’Hara - https://github.com/ryan-copperleaf * webrunners - https://github.com/webrunners - +* Simone Pellizzari - https://github.com/simone6021