Improve changelogging backend usage #19340
jakub-krysl-ipf
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Tip
box belowWhen migrating

ipfabric_netbox
to usenetbox_branching
, I got stuck for quite some time figuring out why updating does not work. TheObjectChange
was missingprechange_data
and I could not see where it's created for the backend. After reading and understanding all the code related to creating theObjectChange
for given instance and finding nothing, I resorted to reading through all the docs. There I stumbled on this note inCustomization -> Custom Scripts
:This put me on right track and I went through every call to alter existing objects and added
instance.snapshot()
before theinstance.save()
. There is one place where I had to do more extensive changes, usage ofqueryset.update_or_create()
. Turns out the requirement for callinginstance.snapshot()
makes usage of this handy method impossible. This seems like a big downside.But all this hassle seems really unnecessary.
Currently the
instance.snapshot()
is called in frontend (defined inviews
) when it actually is doing backend work. Also the requirement to callinstance.snapshot()
produces bug in NetBox itself, where it's forgotten on related objects update, for example #11444.Tip
Let's have only single
instance.snapshot()
call insignals.py
just before callingto_objectchange()
instead and drop the rest.netbox/netbox/core/signals.py
Line 79 in 0f4afbc
This assumes the
instance
is serializable at that point, which it should be sinceto_objectchange
calls serialization for UPDATE right away.netbox/netbox/netbox/models/features.py
Line 110 in 0f4afbc
Beta Was this translation helpful? Give feedback.
All reactions