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 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)