Skip to content

Document how to generate Pre-Change Data for existing objects on the Custom Scripts page #9651

@hagbarddenstore

Description

@hagbarddenstore

Change Type

Addition

Area

Functionality/features

Proposed Changes

The documentation page for Custom Scripts covers how to create new objects, but doesn't cover the caveats when updating an existing object.

Suggestion

Writing Custom Scripts

....the already existing text...

To generate the correct change log data when editing an existing object, a snapshot of the object must be taken before making any changes to the object.

if obj.pk and hasattr(obj, 'snapshot'):
    obj.snapshot()

obj.property = "New Value"

obj.save()

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: documentationA change or addition to the documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions