Skip to content

Create proper change log data when updating objects in custom scripts with NetBox 2.11 #6491

Answered by jeremystretch
netsandbox asked this question in Q&A
Discussion options

You must be logged in to vote

Snapshots aren't taken automatically because doing so effectively saves a copy of the object on itself. This is obviously wasteful if scenarios where there's no intent to modify and save the object.

Is this the correct way?

Yes, calling snapshot() on the instance will capture the pre-change data.

Maybe it makes sense to add such method also to ChangeLoggingMixin

It's probably worth discussing further as a feature request.

Do I now have to rewrite my custom scripts to separate object create and object update

Yes, because it's not possible to capture the pre-change state of an object when writing to the database directly.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ryanmerolle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants