Make API now search in both title and extracts

parent 4e3c6946
Pipeline #1207 passed with stages
in 1 minute and 58 seconds
from django.db.models import Q
from rest_framework import viewsets, mixins
from rp.models import Article
......@@ -16,7 +18,8 @@ class ArticleSearch(viewsets.ModelViewSet, mixins.ListModelMixin):
serializer_class = ArticleSerializer
def list(self, request, *args, **kwargs):
self.queryset = self.queryset.filter(title__icontains=kwargs['search_keywords'])
self.queryset = self.queryset.filter(Q(title__icontains=kwargs['search_keywords'])
| Q(extracts__icontains=kwargs['search_keywords']))
return super().list(request, args, kwargs)
class ArticleTag(viewsets.ModelViewSet, mixins.ListModelMixin):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment