netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Maintain a list of modified fields on each instance of a change-logged model

Open jeremystretch opened this issue 3 years ago • 3 comments

NetBox version

v3.3-beta1

Feature type

New functionality

Proposed functionality

Implement a mechanism for tracking which attributes (if any) of a pre-existing instance have been modified from their original values. For example, when retrieving a site object from the database and then modifying the instance's name, automatically flag the name field as having been modified. This can be done by defining a list of fields named _changed_fields on the instance.

Use case

Being able to infer which fields of an instance have been modified unlocks some very interesting potential.

  1. It obviates the need to manually call snapshot() on each instance in a view: This can be handled automatically on the first change to a field.
  2. It enables responsive updates of denormalized (cached) database fields on other models (see #9788).

Database changes

No response

External dependencies

No response

jeremystretch avatar Aug 02 '22 13:08 jeremystretch

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

github-actions[bot] avatar Oct 02 '22 04:10 github-actions[bot]

A variation of the approach described above has been implemented as part of #6347 (cached device & VM component counts) for NetBox v3.6. We can likely iterate on that work to achieve a more general purpose solution.

jeremystretch avatar Jul 25 '23 13:07 jeremystretch