Skip to content

Conversation

@bctiemann
Copy link
Contributor

Fixes: #20114

When tags are present, the _save_m2m method of BaseModelForm causes the instance to be forcibly saved via f.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 to save:

# Set parent_bay reverse relationship
if device_bay := self.cleaned_data.get('device_bay'):
self.instance.parent_bay = device_bay

The _save_m2m behavior normally leaves parent_bay alone, but if tags are present, this intermediary save_form_data has the effect of regenerating the saved obj and clearing out the synthetic parent_bay attribute.

This fix ensures parent_bay survives this process by pulling it from the object_form.instance prior to calling the save chain, rather than assuming the result of save will still have parent_bay.

@bctiemann bctiemann requested review from a team and jnovinger and removed request for a team December 19, 2025 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk device import no longer works with parent/child devices when "tags" present in import data

2 participants