I use django-simple-history:
http://django-simple-history.readthedocs.io/en/latest/
I have a model that I would like to apply to a method in a historical instance. Example:
from simple_history.models import HistoricalRecords
class Person(models.Model):
firstname = models.CharField(max_length=20)
lastname = models.CharField(max_length=20)
history = HistoricalRecords()
def fullName(self):
return firstname + lastname
person = Person.objects.get(pk=1)
for historyPerson in person.history:
historyPerson.fullName()
Since the HistoricalPerson class does not inherit Person methods. But using Person methods really makes sense, because they have the same fields.
Any solution for this? I would prefer something simple rather than as a duplication of each method in my models for instances of history.
source
share