Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
rpteam
rp
Commits
566e90f9
Verified
Commit
566e90f9
authored
Sep 11, 2017
by
Thibaut Broggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tags in article API responses
parent
04bcd303
Pipeline
#1205
passed with stages
in 1 minute and 57 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
apps/rp/api/serializers.py
apps/rp/api/serializers.py
+12
-1
No files found.
apps/rp/api/serializers.py
View file @
566e90f9
from
rest_framework
import
serializers
from
taggit.managers
import
TaggableManager
from
rp.models
import
Article
class
TagListSerializer
(
serializers
.
Field
):
class
Meta
:
model
=
TaggableManager
(
blank
=
True
)
def
to_representation
(
self
,
obj
):
if
type
(
obj
)
is
not
list
:
return
[
tag
.
name
for
tag
in
obj
.
all
()]
return
obj
class
ArticleSerializer
(
serializers
.
ModelSerializer
):
tags
=
TagListSerializer
()
class
Meta
:
model
=
Article
fields
=
(
'id'
,
'url'
,
'title'
,
'extracts'
,
'und_score_up'
,
'und_score_down'
)
fields
=
(
'id'
,
'url'
,
'title'
,
'
tags'
,
'
extracts'
,
'und_score_up'
,
'und_score_down'
)
Write
Preview
Markdown
is supported
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