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

Added support for adding meta objects from serializers #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
jsenecal merged 5 commits into develop from feature/meta
Dec 17, 2015

Conversation

Copy link
Member

@jerel jerel commented Dec 11, 2015

Solves #154.

By declaring a meta_fields property on the serializer's Meta class meta data can be added to the:

  • meta key of each item in a list serializer (a blog entry)
  • meta key of a single data object (a blog)

By declaring a get_root_meta function on a serializer data can be added to the:

  • top level meta object
{
 "data": [
 {
 "type": "entry",
 "id": "1",
 "attributes": {
 "title": "Test",
 },
 // set by EntrySerializer `meta_fields`
 "meta": {
 "bodyFormat": "text"
 }
 }
 ],
 // set by the `get_root_meta` function on EntrySerializer
 "meta": {
 "bar": "Baz"
 },
}

Copy link
Member

Nice work here @jerel :)

@jerel jerel changed the title (削除) [WIP] Added support for meta objects in serializers and list serializers (削除ここまで) (追記) Added support for adding meta objects from serializers (追記ここまで) Dec 14, 2015
Copy link
Member Author

jerel commented Dec 14, 2015

This is ready for review and feedback or merge

jsenecal added a commit that referenced this pull request Dec 17, 2015
Added support for adding meta objects from serializers
@jsenecal jsenecal merged commit 79b7c79 into develop Dec 17, 2015
@jsenecal jsenecal deleted the feature/meta branch December 17, 2015 18:22
Copy link

Elawphant commented Dec 6, 2022
edited
Loading

It seems, this does not work as expected.
I have extended rest_framework_json_api.serializers.ModelSerializer, added rest_framework_json_api.serializers.SerializerMethodField and get_my_field method to the serializer, and added my_field to Meta's meta_fields. However, instead of meta, my_field has appeared inside data.
get_root_meta on the serializer does nothing, either.

Copy link
Contributor

auvipy commented Dec 7, 2022

I think you should open a PR with a failing test

sliverc reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

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