質問編集履歴

1

追記

2020/08/09 07:53

投稿

Mario_11
Mario_11

スコア95

test CHANGED
File without changes
test CHANGED
@@ -100,7 +100,15 @@
100
100
 
101
101
  context = {}
102
102
 
103
- context['all_post_category_list'] = Post.objects.annotate(category_count=Count('category')).order_by('-category')
103
+ lst = [p.get_category_display for p in Post.objects.order_by('-category')]
104
+
105
+ context['all_post_category_list'] = Counter(lst)
106
+
107
+ print(Counter(lst))#追加
108
+
109
+
110
+
111
+
104
112
 
105
113
  context['all_subpost_category_list'] = SubPost.objects.annotate(category_count=Count('category')).order_by('-category')
106
114