-
Notifications
You must be signed in to change notification settings - Fork 492
Open
Description
When a project contains multiple user models that can edit the same model, it’s not possible to add history.
The issue arises because HistoricalRecords enforces a single user_model, which doesn’t work when different types of users can modify the same object.
Example:
class BusinessOwnerUser(models.Model):
name = models.CharField(max_length=150, null=True, blank=True)
class CustomerUser(models.Model):
name = models.CharField(max_length=150, null=True, blank=True)
class Invoice(models.Model):
title = models.CharField(max_length=150, null=True, blank=True)
history = HistoricalRecords()
if a customer user changes the Invoice there is an error
"Cannot assign \"<CustomerUser: 7 7>\": \"HistoricalInvoice.history_user\" must be a \"BusinessOwnerUser\" instance.
I've tried:
- leave the user_model parameter for HistoricalRecords empty
- use BusinessOwnerUser as user_model parameter
- use a list of user_model parameter for HistoricalRecords
- write a custom history_user_setter:
def set_historical_user_none(historical_instance):
historical_instance.history_user_id = None
I think it would be nice to have an option to disable user_model if needed OR to allow multiple user models to be linked to the historical model.
Metadata
Metadata
Assignees
Labels
No labels