Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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" (8ea956c).Also:
delete_without_historical_record()
to all history-tracked model objects, which complementssave_without_historical_record()
(e2894b5)Breaking changes:
HistoryManager.get_super_queryset()
(23c37dd)utils
functionsget_history_manager_from_history()
toget_historical_records_of_instance()
andget_app_model_primary_key_name()
toget_pk_name()
(23c37dd)Deprecations:
HistoricalRecords.thread
- useHistoricalRecords.context
instead. The former attribute will be removed in version 3.10 (74a2e38)skip_history_when_saving
in favor of the newly addeddisable_history()
context manager. The former attribute will be removed in version 4.0 (8ea956c)Fixes and improvements:
utils
functionsget_history_manager_for_model()
andget_history_model_for_model()
now explicitly support being passed model instances instead of just model types (78286f6)Other changes:
create_historical_record()
(7755c1e)Related Issue
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
Checklist:
pre-commit run
command to format and lint.AUTHORS.rst
CHANGES.rst