Skip to content

Commit

Permalink
Fix netbox-community#12983 bulk edit of M2M fields when nothing is se…
Browse files Browse the repository at this point in the history
…lected

Partially revert 41c9248 to restore
bulk edit with m2m fields. The m2m cleaned_data yields a empty queryset
when nothing is selected. By setting the m2m relation unless set null is
checked even when nothing is selected the m2m relation is always
cleared.

This commit only sets the m2m relation when a selection is made.
  • Loading branch information
Urth committed Jun 26, 2023
1 parent d131d9b commit 5c21555
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion netbox/netbox/views/generic/bulk_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def _update_objects(self, form, request):
for name, m2m_field in m2m_fields.items():
if name in form.nullable_fields and name in nullified_fields:
getattr(obj, name).clear()
else:
elif form.cleaned_data[name]:
getattr(obj, name).set(form.cleaned_data[name])

# Add/remove tags
Expand Down

0 comments on commit 5c21555

Please sign in to comment.