Skip to content

SerializerMethodResourceRelatedField does not include meta section in relationship response. #572

@BillBrower

Description

@BillBrower

SerializerMethodResourceRelatedField does not include a meta section in the relationship response like ResourceRelatedField does. This doesn't make sense, because SerializerMethodResourceRelatedField extends ResourceRelatedField and both seem to return every related record in the response (for the record I've only tried with a little over a thousand related records).

So for example if you had an ObjectA with a has many relationship with ObjectB:

    objectbs = SerializerMethodResourceRelatedField(
        source='get_objectbs',
        many=True,
        model=ObjectB,
        read_only=True
    )

    def get_objectbs(self, obj):
        return ObjectB.objects.filter(objecta=obj)

then your response would look like:

"relationships": {
  "objectb": {
   "data": [...]
  }
}

instead of:

"relationships": {
  "objectb": {
    "meta": {
      "count": 2
    },
   "data": [...]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions