Description
Hi there!
I have a particular use case here: I have a denormalized table that contains one data type (let's call it 'pieces') that gets aggregated up to another model (let's call them 'pies').
Since I can't do anything with pies without having all of the pieces (technical requirement), I've decided to keep a table representing only the pieces and aggregate up to the pie level when pies are asked for.
I noticed this line in the renderer code:
('id', encoding.force_text(resource_instance.pk) if resource_instance else None),
It's in the method build_json_resource_obj
Since my dataset has many repeats of the pie IDs, I can't use it as a pk, BUT once I aggregate the table the Pie Viewset, it IS unique. Since it is not the actual pk on the model, however, I get the error 'dict' object has no attribute 'pk'
.
The ideal situation would be that I can set the pie ID as the id in the JSON API representiation.
Is there a built-in way to handle this sort of use case?