Description
Describe the bug
I use a postgres database. I call the update_change_reason method in a post_create_historical_record signal and my model has a nullable JSONField. It raises an AttributeError 'NoneType' object has no attribute 'history_change_reason'.
To Reproduce
Steps to reproduce the behavior:
- Create a model with a null JSONField on a project with a postgres database.
- Register the history on all fields.
- Call the update_change_reason method.
- It raises an AttributeError 'NoneType' object has no attribute 'history_change_reason'.
Expected behavior
No error raised.
Screenshots
Environment (please complete the following information):
- OS: MacOS 13.3.1
- Django Simple History Version: 3.3.0
- Django Version: 4.0.1
- Database Version: PostgreSQL 14.8
Additional context
The problem is that update_change_reason makes this request : model.objects.filter(json_field=None)
For a postgres JSONField, None means that there is a null value and in this case there is no null value just an empty field.
I tried to override locally the update_change_reason method to make this request for the null jsonfield: model.objects.filter(json_field__isnull=True) and it works.
If it's usefull I can open a pull request with this change.