Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to work with serializers.Serializer? #925

Answered by SafaAlfulaij
SafaAlfulaij asked this question in Q&A
Discussion options

How to work with the base Serializer?
How to include it? How to give it a pk?
I saw that some code got deprecated at a point of a time: ab3fbfc#diff-52135bfc77d9d40d99d5451d1c64e64d75f0ae5bd338162064891dfcfc27b3b0L114

Currently, it shows as a simple JSON field in the returned data.

You must be logged in to vote

I think it can just live as a simple attribute, not as an included resource.
That's after a bit of thinking, and checking the folks at JSON:API forums.

Replies: 1 comment 1 reply

Comment options

I think it can just live as a simple attribute, not as an included resource.
That's after a bit of thinking, and checking the folks at JSON:API forums.

You must be logged in to vote
1 reply
Comment options

You have two ways either you nest it as an attribute simply as nested serializer (possible since version 3.2.0) or you define its own endpoint and connect it with SerializerMethodResourceRelatedField.

In the latter case the object it handles need to have a pk property (also see #155) defining the primary key.

Answer selected by SafaAlfulaij
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #913 on April 18, 2021 18:35.

AltStyle によって変換されたページ (->オリジナル) /