Skip to content

Commit

Permalink
Fixes #13376: Restrict add/remove tag fields by model on bulk edit forms
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Aug 4, 2023
1 parent 2afce6c commit f1c182b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions netbox/netbox/forms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ def __init__(self, *args, **kwargs):

self.fields['pk'].queryset = self.model.objects.all()

# Restrict tag fields by model
ct = ContentType.objects.get_for_model(self.model)
self.fields['add_tags'].widget.add_query_param('for_object_type_id', ct.pk)
self.fields['remove_tags'].widget.add_query_param('for_object_type_id', ct.pk)

self._extend_nullable_fields()

def _get_form_field(self, customfield):
Expand Down

0 comments on commit f1c182b

Please sign in to comment.