1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
from django.db import models
from simple_history import register
from simple_history.models import HistoricalRecords
from simple_history.tests.custom_user.models import CustomUser
class AbstractExternal(models.Model):
history = HistoricalRecords(inherit=True)
class Meta:
abstract = True
class AbstractExternal2(models.Model):
history = HistoricalRecords(inherit=True, custom_model_name=lambda x: f"Audit{x}")
class Meta:
abstract = True
app_label = "external"
class AbstractExternal3(models.Model):
history = HistoricalRecords(
inherit=True, app="external", custom_model_name=lambda x: f"Audit{x}"
)
class Meta:
abstract = True
app_label = "external"
class ExternalModel(models.Model):
name = models.CharField(max_length=100)
history = HistoricalRecords()
class ExternalModelRegistered(models.Model):
name = models.CharField(max_length=100)
register(ExternalModelRegistered, app="simple_history.tests", manager_name="histories")
class ExternalModelWithCustomUserIdField(models.Model):
name = models.CharField(max_length=100)
history = HistoricalRecords(history_user_id_field=models.IntegerField(null=True))
class Poll(models.Model):
"""Test model for same-named historical models
This model intentionally conflicts with the 'Polls' model in 'tests.models'.
"""
history = HistoricalRecords(user_related_name="+")
|