質問編集履歴

1

viewsを追加しました

2016/10/29 09:25

投稿

sizumita
sizumita

スコア196

test CHANGED
File without changes
test CHANGED
@@ -38,6 +38,36 @@
38
38
 
39
39
  </form>
40
40
 
41
+
42
+
43
+ #views
44
+
45
+
46
+
47
+ def index_Search(request):
48
+
49
+ forms = Search(request.GET)
50
+
51
+ if ('q' in request.GET) and request.GET['q'].strip():
52
+
53
+ query_string = request.GET['q']
54
+
55
+ entry_query = get_query(query_string, ['title', 'body',])
56
+
57
+ book = Book.objects.filter(entry_query).order_by('-pub_date')
58
+
59
+ else:
60
+
61
+ book = Book.objects.all().order_by('-pub_date')
62
+
63
+ return render(request,
64
+
65
+ 'cms/search.html', # 使用するテンプレート
66
+
67
+ {'Book': book}) # テンプレートに渡すデータ
68
+
69
+
70
+
41
71
  ```
42
72
 
43
73