django-simple-history
django-simple-history copied to clipboard
`disable_history()` context manager
Description
Added a disable_history() context manager, which disables history record creation while it's active; see usage in the docs under "Disable Creating Historical Records" (8ea956c4067f166642336a32c2c478a55dc14c56).
Also:
- Added
delete_without_historical_record()to all history-tracked model objects, which complementssave_without_historical_record()(e2894b54009298c924c5e70656492a085c404529)
Breaking changes:
- Removed
HistoryManager.get_super_queryset()(23c37dda6c1d70d934ac53bb2f1ef4469a890f9e) - Renamed the
utilsfunctionsget_history_manager_from_history()toget_historical_records_of_instance()andget_app_model_primary_key_name()toget_pk_name()(23c37dda6c1d70d934ac53bb2f1ef4469a890f9e)
Deprecations:
- Deprecated the undocumented
HistoricalRecords.thread- useHistoricalRecords.contextinstead. The former attribute will be removed in version 3.10 (74a2e381bf78b0ca6afe7bb0f12019cdcea72491) - Deprecated
skip_history_when_savingin favor of the newly addeddisable_history()context manager. The former attribute will be removed in version 4.0 (8ea956c4067f166642336a32c2c478a55dc14c56)
Fixes and improvements:
- Moved the "Save without creating historical records" subsection of "Querying History" in the docs to a new section: "Disable Creating Historical Records" (b36a280a4c0eea9a467bb4ee66bc40b9c028edae)
- The
utilsfunctionsget_history_manager_for_model()andget_history_model_for_model()now explicitly support being passed model instances instead of just model types (78286f6f5b691d932c89e56e3e7f5dbbc5608047)
Other changes:
- Documented overriding
create_historical_record()(7755c1e496a4dfeb2e60f3da8546123552048631)
Related Issue
- Closes #642
- Closes #993
- Closes #1365
- Closes #736
Motivation and Context
Having an easier and more universal way of disabling the creation of historical records in various contexts.
How Has This Been Tested?
See the added tests.
Screenshots (if appropriate):
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] I have run the
pre-commit runcommand to format and lint. - [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have read the CONTRIBUTING document.
- [x] I have added tests to cover my changes.
- [x] I have added my name and/or github handle to
AUTHORS.rst - [x] I have added my change to
CHANGES.rst - [x] All new and existing tests passed.
@ddabble I'm pretty swamped through the first week of October right now if you can wait until then.
Sure, no rush 😊