我在我的通知模型中创建了一个 simple_history.models.HistoricalRecords 实例
模型.py
class Notification(models.Model):
title = models.CharField(max_length=500)
content = RichTextField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
history = HistoricalRecords()
class Attachment(models.Model):
title = models.CharField(max_length=500)
attachement = models.FileField(upload_to = user_directory_path)
notifiaction = models.ForeignKey(Notification, on_delete=models.SET_NULL, null= True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
架构.py
class AttachmentNode(DjangoObjectType):
class Meta:
model = Attachment
filter_fields = ['title']
interfaces = (relay.Node, )
class NotificationNode(DjangoObjectType):
class Meta:
model = Notification
filter_fields = {
'id': ['exact'],
'title': ['exact', 'icontains', 'istartswith'],
}
interfaces = (relay.Node, )
class Query(graphene.ObjectType):
notifications = relay.Node.Field(NotificationNode)
all_notifications = DjangoFilterConnectionField(NotificationNode)
这工作正常,但是当我查询通知时,我想要由 HistoricalRecords() 为 graphql 端点中的通知模型创建的所有记录。我怎样才能做到这一点?