-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect tag search - illusory duplicates returned #1692
Comments
@david-kn I tried to reproduce the issue but I was not able to do it. I tried to add more tags through the UI. I am wondering what you get if you run the following in
|
I can confirm this issue. It does not happen in the base Tags list (un-searched), but does appear when a search is issued. |
The below diff appears to fix the issue: diff --git a/nautobot/extras/filters.py b/nautobot/extras/filters.py
index 48a0a4550..338a858a9 100644
--- a/nautobot/extras/filters.py
+++ b/nautobot/extras/filters.py
@@ -977,7 +977,7 @@ class TagFilterSet(NautobotFilterSet):
return queryset
return queryset.filter(
Q(name__icontains=value) | Q(slug__icontains=value) | Q(content_types__model__icontains=value)
- )
+ ).distinct()
# |
Thanks Glen for confirmation :-) To filter and show only distinct values was my inner guess as well. btw. Isn't such a fix a good candidate also for |
Steps to Reproduce
exclude
):Organization
->Tags
page orExpected Behavior
Only existing (unique) tag(s) should be returned.
Observed Behavior
There are too many returned tags (not unique) that are duplicate (as for each model would exist individual tag with the same name). The number of returned duplicate tags correspond with a number of attached models to a given tag (in my case 35)
btw. So far, I noticed this only for
Tags
but not forStatuses
which can also be connected with multiple models.The text was updated successfully, but these errors were encountered: