From 15c7617a7d4a462dcd8474e0b38eff7fb997cc20 Mon Sep 17 00:00:00 2001 From: bug_creator Date: Wed, 1 Dec 2021 12:15:26 +0800 Subject: [PATCH] fix search --- app/main/views.py | 6 +++++- app/templates/querypost.html | 12 ++++++++---- data-dev.sqlite | Bin 6885376 -> 6885376 bytes 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/main/views.py b/app/main/views.py index ff4c41d..fd0a298 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -253,9 +253,13 @@ def query(content): flash("Search content cannot be empty.") return render_template('querypost.html') search_result = "%" + inf + "%" - result = Post.query.filter(or_(Post.title.like(search_result), Post.body.like(search_result))) + print(search_result) + # result = Post.query.filter(or_(Post.title.like(search_result), Post.body.like(search_result))) + result = Post.query.filter(Post.body.like(search_result)) for item in result: item.important = 0 + if(item.title is None): + item.title="" sentence = item.title + item.body counts = 0 list1 = sentence.split(" ") diff --git a/app/templates/querypost.html b/app/templates/querypost.html index f0bed2c..faf520c 100644 --- a/app/templates/querypost.html +++ b/app/templates/querypost.html @@ -69,14 +69,16 @@
@@ -84,7 +86,8 @@
@@ -92,7 +95,8 @@
diff --git a/data-dev.sqlite b/data-dev.sqlite index d0bb7abf937b9096717d0b3d1f410c5a401626ba..97937645f3e9400fd3a136b50b238b725feb9896 100644 GIT binary patch delta 752 zcmZ|M%T5zf7{KwFGxP>@rXr#Rlor$q+B#?2PMIpy;{8&@`&~v5-D{IP>St!dwIq&4`l4VL$Y56j&CA&(FZH_BH z!Y`FnkeOG1EoyI!#Fw=9NB0wLb#XWq?TCr0(%Q6>Z97grXtdRAA{rr2Ra(*Dw;`US zyO~xjn=)6lO>1fL?O1(D3TWs+2w_AJMGT$jLO0^jVIYAm=)qR>VjKFf9XpUjKL#*} zo!EsTq=F@xe)gg#5^pHRXJgtB`Zs+}*W(TD{1lJQEaYNJW+Le)K8jJl(o9DN{&TK$ zN>*KOrZJ2W?8YAKMF#sYiZSfR0c4TGL70%(=#vlhW?@bCZuUR*_Ie>`uNOlt?Wu76 z$ai~92$zMQtG>5tclP~LWN+-Itkii!3FB~3#vvTW1SV0z5mYgSqd11+IDwNmh0{2L zvp9zurg0uKxPXhegv+>stGI^ixPhCvh1T9ySU_T7L_rKuGl4RA z0R&PdJ^(5nkSdhD5|vmx@d3(=K;}REp5a*@J@tPGPr(me>F1UcX=r`=P%W^-WZKY*>F}KLb6#^y>r1)* zS0q-Z%o|2tQODHe-%8M{`>q@K>9h~B%GiYg?8YAK#XbyTKMvp^4xxf74#S3o12+{*-m2`D71u6F zFLG*;FRQi___o)`*1R-Z^YtIvGqs)+z6Yz!zf+R99dtID?EpgvQA30yIErB$!w5z( zhH)In37o_!oW>cP#W|eE1ST11nEc}a