from django.db import models from simple_history.models import HistoricalRecords class Book(models.Model): title = models.CharField(max_length=100) author = models.CharField(max_length=100) published_date = models.DateField() history = HistoricalRecords()
from django.db import models from simple_history.models import HistoricalRecords class Customer(models.Model): name = models.CharField(max_length=100) address = models.CharField(max_length=200) email = models.EmailField() history = HistoricalRecords() def __str__(self): return self.nameIn this example, the HistoricalRecords is used to track changes in the Customer model. The history object can be accessed to retrieve the history of changes made to an object. The __str__ method is overridden to display the name of the customer instance. Overall, Python simple_history.models HistoricalRecords is an efficient package library for keeping track of changes made to objects and their previous versions.