Preserve parent_bay during device bulk import when tags are present #21019
+3
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #20114
When tags are present, the
_save_m2mmethod ofBaseModelFormcauses the instance to be forcibly saved viaf.save_form_data(self.instance, cleaned_data[f.name]). However, because we detect the presence of a device's parent device bay by stashing it on the instance prior tosave:netbox/netbox/dcim/forms/bulk_import.py
Lines 730 to 732 in ff97ab9
The
_save_m2mbehavior normally leavesparent_bayalone, but if tags are present, this intermediarysave_form_datahas the effect of regenerating the savedobjand clearing out the syntheticparent_bayattribute.This fix ensures
parent_baysurvives this process by pulling it from theobject_form.instanceprior to calling thesavechain, rather than assuming the result ofsavewill still haveparent_bay.