Skip to content

Commit 86d366b

Browse files
committed
Fixes #9651 - Document Pre-Change process for scripts
1 parent 1b62c11 commit 86d366b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/customization/custom-scripts.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,19 @@ The Script object provides a set of convenient functions for recording messages
129129

130130
Log messages are returned to the user upon execution of the script. Markdown rendering is supported for log messages.
131131

132+
## Change Logging
133+
134+
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.
135+
136+
```python
137+
if obj.pk and hasattr(obj, 'snapshot'):
138+
obj.snapshot()
139+
140+
obj.property = "New Value"
141+
obj.full_clean()
142+
obj.save()
143+
```
144+
132145
## Variable Reference
133146

134147
### Default Options

0 commit comments

Comments
 (0)