回答編集履歴

1

追記

2020/12/29 03:32

投稿

quickquip
quickquip

スコア11231

test CHANGED
@@ -7,3 +7,53 @@
7
7
 
8
8
 
9
9
  なので`{{ post.rank }}`ですね
10
+
11
+
12
+
13
+ ----
14
+
15
+
16
+
17
+ ```python
18
+
19
+ def listfunc(request):
20
+
21
+ posts = Book.objects.all()
22
+
23
+ dictionary = []
24
+
25
+ for i in posts:
26
+
27
+ dictionary.append(i.__dict__)
28
+
29
+ dictionary_sorted = sorted(dictionary, key=lambda x:x['rank'])
30
+
31
+ print(dictionary_sorted)
32
+
33
+ return render(request, 'list.html', {'posts': posts})
34
+
35
+ ```
36
+
37
+
38
+
39
+ ```python
40
+
41
+ def listfunc(request):
42
+
43
+ posts = Book.objects.all()
44
+
45
+ dictionary = []
46
+
47
+ for i in posts:
48
+
49
+ dictionary.append(i.__dict__)
50
+
51
+ dictionary_sorted = sorted(dictionary, key=lambda x:x['rank'])
52
+
53
+ print(dictionary_sorted)
54
+
55
+ return render(request, 'list.html', {'dictionary_sorted': dictionary_sorted})
56
+
57
+ ```
58
+
59
+ じゃないでしょうか。