Implemented basic search functionality

This commit is contained in:
Mike Young
2019-12-13 01:43:18 -05:00
parent 0bef88d1f3
commit 0eeb23c52c
5 changed files with 22 additions and 13 deletions

View File

@@ -35,7 +35,10 @@ class Books(models.Model):
return reverse("model-detail-view", args=[str(self.id)])
def generic_search(self, query):
results = Books.objects.annotate(
search=SearchVector("author", "title", "file_name")
).filter(str(query))
try:
results = Books.objects.annotate(
search=SearchVector("author", "title", "file_name"),
).filter(search=query)
except Exception as e:
raise
return results