林轩 пре 1 година
родитељ
комит
cc9b923f86
1 измењених фајлова са 2 додато и 1 уклоњено
  1. 2 1
      apps/PestAnalysis/views.py

+ 2 - 1
apps/PestAnalysis/views.py

@@ -198,8 +198,9 @@ class RecentMonthPestCount(GenericAPIView):
             for k, v in result.items():
                 if k in insect_dict.keys():
                     temp[insect_dict.get(k)] = v 
+            temp = sorted(temp.items(), key=lambda item: item[1], reverse=True)
             data = {
-                "pest": temp,
+                "pest": dict(temp),
                 "imgs": imgs[:10]
             }
             return Response(data)