我正在使用django-simple-history保存django模型中每个更改的更改历史记录。
我尝试过的:
class MyModel(models.models):
field1 = ...
...
history = HistoricalRecords(
history_change_reason_field=models.TextField(null=True)
)
name = 'xyz'
for doc_id, status in my_data:
reporting , _ = MyModel.objects.get_or_create(
doc_id=doc_id,
user=self.request.user
)
reporting.is_accepted = status
reporting.save(
update_fields=['is_accepted']
)
update_change_reason(
instance=reporting,
reason=f'Change request done by {name}'
)
,我得到以下错误。
AttributeError: 'NoneType' object has no attribute 'history_change_reason'