我正在使用嵌套关系来返回分组消息,并且想知道如何对嵌套消息进行排序,以便它们按时间顺序排列。
class MessageGroupResource(ModelResource):
messages = fields.ToManyField('lookup.api.MessageResource', 'message_set', full=True);
class Meta:
queryset = MessageGroup.objects.all();
resource_name = 'message'
authorization= UserAuthorization()
ordering = [
'sendTime',
]
class MessageResource(ModelResource):
messageGroup = fields.ForeignKey(MessageGroupResource, 'messageGroup')
class Meta:
queryset = Message.objects.all()
resource_name = 'submessage'
authorization= UserAuthorization()