django-simple-history
django-simple-history copied to clipboard
Set HistoricalRecord base class globally
Problem Statement
Is it possible to set the base class(s) for HistoricalRecord
globally?
- So platform wide fields can be set in one place instead of on every instantiation of
HistoricalRecord
(as described here)
Describe the solution you'd like
Ability to set base classes for HistoricalRecord
globally.
Describe alternatives you've considered
- Patching logic directly into
HistoricalRecord
. - Overriding
HistoricalRecord
and using the override everywhere instead + linter to prevent accidental bypass of the overridden class.
Not sure what your looking for. But, I hope this helps
Create a Model base class and add the history attribute
class CommonBaseModel(models.Model):
history = HistoricalRecords(
inherit=True,
bases=[RoutableModel, ]
)
class Meta:
abstract = True
Then when you create your models you'll have the settings you require in the parent class
class SomeModel(CommonBaseModel):
question = models.CharField(max_length=200)