回答編集履歴
3
修正
test
CHANGED
@@ -10,4 +10,10 @@
|
|
10
10
|
|
11
11
|
return render(request, "blog_category.html", context)
|
12
12
|
|
13
|
+
```urls↓
|
14
|
+
|
15
|
+
```Python
|
16
|
+
|
17
|
+
path("<slug:category>/", views.blog_category, name="blog_category"),
|
18
|
+
|
13
19
|
```
|
2
修正
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Blog
|
1
|
+
BlogとCategoryはManyToManyFieldでつないでいますよね。だったら、
|
2
2
|
|
3
3
|
```Python
|
4
4
|
|
1
修正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
def blog_category(request, category):
|
6
6
|
|
7
|
-
posts = Post.objects.filter(categories__in=category)
|
7
|
+
posts = Post.objects.filter(categories__in=[category])
|
8
8
|
|
9
9
|
context = {"category": category, "posts": posts}
|
10
10
|
|