question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document include options for Compound Documents

See original GitHub issue

With #250 pulled in we now have options to include relations to form compound documents:

  1. Include resources related to the primary data by default.
  2. Include resources related to the primary data through use of a request parameter which customizes which related resources should be returned

Example Current Implementation

  1. default include posts
class UserSerializer(serializers.Serializer):
    name = serializers.CharField(max_length=200)
    # PostSerializer included directly on the serializer
    posts = PostSerializer(many=True, read_only=True)

    class JSONAPIMeta:
        # included_resources specifys resources to include by default
        included_resources = ['posts']
  1. param include posts
class UserSerializer(serializers.Serializer):
    name = serializers.CharField(max_length=200)
    # PostSerializer NOT included directly on the serializer, ResourceRelatedField is 
    # specified as default
    posts = relations.ResourceRelatedField(
            source='post_set', many=True, read_only=True) 

    # specifies serializer to use when passing in the `include` param
    included_serializers = {
        'posts': PostSerializer,
    }

We should probably document this. We can even copy the examples above with a bit of explanation.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mblaymancommented, Dec 8, 2016

Since this was still open, I took a crack at documenting it in PR #308.

1reaction
timmyomahonycommented, Jan 18, 2017

Thanks for this. I had to find this post to make sense of included records. It would be great to get some official documentation for this. It’s a common pattern for sideloading data in Ember for example

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with compound documents - IBM
Working with compound documents. Table 1. This table provides the available procedures you can perform when working with parent and child documents.
Read more >
Compound Documents - CloudNine Answer Center
Compound documents are composed of a container document and embedded documents. For example, a Word document may contain an embedded spreadsheet.
Read more >
Compound Documents - Win32 apps | Microsoft Learn
OLE compound documents enable users working within a single application to manipulate data written in various formats and derived from multiple ...
Read more >
Compound document - Wikipedia
Compound documents are often produced using word processing software, and may include text and non-text elements such as barcodes, spreadsheets, pictures, ...
Read more >
CompoundDocuments
A compound document contains various types of information (formatted text, ... Compound documents are stored in binary files with the .odc extension.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found