Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
567ce597
Verified
Commit
567ce597
authored
Sep 11, 2017
by
Thibaut Broggi
Browse files
Make API now search in both title and extracts
parent
4e3c6946
Pipeline
#1207
passed with stages
in 1 minute and 58 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
apps/rp/api/views.py
View file @
567ce597
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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment