diff --git a/CHANGES.rst b/CHANGES.rst index d5af46459..40c8852ff 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,8 @@ Unreleased - Dropped support for Django 4.0, which reached end-of-life on 2023-04-01 (gh-1202) - Added support for Django 4.2 (gh-1202) - Made ``bulk_update_with_history()`` return the number of model rows updated (gh-1206) +- Fixed ``HistoryRequestMiddleware`` not cleaning up after itself (i.e. deleting + ``HistoricalRecords.context.request``) under some circumstances (gh-1188) 3.3.0 (2023-03-08) ------------------ diff --git a/docs/common_issues.rst b/docs/common_issues.rst index 1e932fea5..aaba81a8b 100644 --- a/docs/common_issues.rst +++ b/docs/common_issues.rst @@ -124,29 +124,6 @@ Tracking Custom Users cannot be set directly on a swapped user model because of the user foreign key to track the user making changes. -Using django-webtest with Middleware ------------------------------------- - -When using django-webtest_ to test your Django project with the -django-simple-history middleware, you may run into an error similar to the -following:: - - django.db.utils.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`test_env`.`core_historicaladdress`, CONSTRAINT `core_historicaladdress_history_user_id_0f2bed02_fk_user_user_id` FOREIGN KEY (`history_user_id`) REFERENCES `user_user` (`id`))') - -.. _django-webtest: https://github.com/django-webtest/django-webtest - -This error occurs because ``django-webtest`` sets -``DEBUG_PROPAGATE_EXCEPTIONS`` to true preventing the middleware from cleaning -up the request. To solve this issue, add the following code to any -``clean_environment`` or ``tearDown`` method that -you use: - -.. code-block:: python - - from simple_history.middleware import HistoricalRecords - if hasattr(HistoricalRecords.context, 'request'): - del HistoricalRecords.context.request - Using F() expressions --------------------- ``F()`` expressions, as described here_, do not work on models that have