Skip to content

Commit 10e7659

Browse files
Closes #20332: Add a "none" option to object tag filters (#20452)
1 parent 1886258 commit 10e7659

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

netbox/utilities/forms/fields/fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22

33
from django import forms
4+
from django.conf import settings
45
from django.db.models import Count
56
from django.forms.fields import JSONField as _JSONField, InvalidJSONInput
67
from django.templatetags.static import static
@@ -74,7 +75,8 @@ def get_choices():
7475
count=Count('extras_taggeditem_items')
7576
).order_by('name')
7677
return [
77-
(str(tag.slug), '{} ({})'.format(tag.name, tag.count)) for tag in tags
78+
(settings.FILTERS_NULL_CHOICE_VALUE, settings.FILTERS_NULL_CHOICE_LABEL), # "None" option
79+
*[(str(tag.slug), f'{tag.name} ({tag.count})') for tag in tags]
7880
]
7981

8082
# Choices are fetched each time the form is initialized

0 commit comments

Comments
 (0)