Passing the parent instance to a nested model serializer #9083
-
Dear community, I’m currently struggling with an issue around nested serializers. I’m trying to implement a linked data renderer (JSON-LD, Turtle, RDF-XML, etc.) for DRF. It’s going well for flat properties, but I’m struggling with nested presentations. I’d like to create a nested serializer that doesn’t act on a specific attribute of the model instance, but the model instance itself. Suppose you have an event model:
Using a ModelSerializer, this will give you a flat presentation of the date. In linked data use cases, attributes are often described in a richer way, like this:
So what I’d like to do is this:
Any ideas? I left out all the linked data parts in the example to make it easier to understand. Any help appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ok, RTFM. Just pass |
Beta Was this translation helpful? Give feedback.
Ok, RTFM. Just pass
source="*"
.