For my CRM I am trying to create an History model, that should store every change or action made on a specific Ticket (aka Customer Request). In this scenario two type of users are involved: Resources and Customers.
Since both can make an action that should be stored in the History table (ex. Customers can open the ticket and Resources can close it)
I was wondering what is the right way to achieve this as a Foreign Key (actor
)
class TicketHistory(models.Model):
ticket = models.ForeignKey("Tickets", on_delete=models.PROTECT, related_name="ticket")
action = models.ForeignKey("HistoryActions", on_delete=models.PROTECT, related_name="action")
resourceActor = models.ForeignKey("Resources", ...)
customerActor = models.ForeignKey("CustomerUsers" ...)
date = models.DateTimeField(auto_now_add=True)
As you can see I've initially decided to create two different fields, but I don't think it is the best solution. How would you do this?