Django simple story - using model methods?

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) # Person instance
for historyPerson in person.history:
    historyPerson.fullName() # wont work.

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.

+4
source share

All Articles