如果继承ApiView想要实现排序

example

res = EventLog.objects.filter(user__role='DOCTOR').values("user_id").annotate(Count("user_id")).order_by("user_id")

res_data = Active_Ranking1(instance=res,many=True)

serializer_data = sorted(res_data.data, key=lambda k: k['active_times'], reverse=True) #通过这行实现排序功能

时间字段序列化的时候

工作笔记1-时间字段序列化

 

相关文章:

  • 2021-05-02
  • 2021-07-14
  • 2022-12-23
  • 2021-10-09
  • 2021-06-12
  • 2021-05-03
  • 2021-09-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-04
  • 2021-04-04
  • 2021-08-16
  • 2021-07-22
  • 2021-10-23
  • 2021-08-11
相关资源
相似解决方案