如何告诉 DSH 索引特定字段?我对历史模型所做的一些查询花费了太多时间
我有基础抽象模型,我所有的模型都继承自该模型。历史字段也在这个基本模型中定义:
class BaseModel(models.Model):
class PublishingStatus(models.TextChoices):
DRAFT = 'draft', _('Draft')
ACCEPTED = 'accepted', _('Accepted'),
REJECTED = 'rejected', _('Rejected'),
MODIFIED = 'modified', _('Modified')
publishing_status = models.CharField(
max_length=9,
choices=PublishingStatus.choices,
default=PublishingStatus.DRAFT,
help_text=_("Publishing status represents the state of the object. By default it is 'draft'")
)
history = HistoricalRecords(inherit=True)
我还在这个基本模型中添加了索引
class Meta:
abstract = True
indexes = [models.Index(fields=[
'publishing_status',
])]
如果 Django Simple History 可以检查哪些字段被索引并在历史模型中创建相同的索引,那就太好了
也许有一种方法可以明确地告诉 django 简单历史必须另外索引哪个字段?