Open cerahmed opened 1 year ago
I have the same issue, once you get past the first level of nesting POST
and PUT
return the parent_pk key error. Have you found a workaround @cerahmed
@JayCeeJr Unfortunately I did not. However I moved to using drf-nested-resources as a working alternative, which solved my issue. Make sure to read my closed issue in that repo tho, you may run in the same issue that I encountered there.
@JayCeeJr Unfortunately I did not. However I moved to using drf-nested-resources as a working alternative, which solved my issue. Make sure to read my closed issue in that repo tho, you may run in the same issue that I encountered there.
it's not maintained for 5 years now :/
it's not maintained for 5 years now :/
Yeah that's unfortunate; good thing is it still works for me. I've seen some updates to this repo, wondering if anyone tried this recently and it got fixed?
I have the following two simplified models:
With serializers:
With viewsets:
and finally urls:
Everything works fine, I can GET
http://localhost/relays/8/logs/
andhttp://localhost/relays/8/logs/16
to list and show detail for the specific relay logs, respectively.However, when looking at
http://localhost/relays/8/logs/
and try to post a new relay log, or when looking athttp://localhost/relays/8/logs/14
and try to PUT to change some fields on it, I get aKeyError at /relays/8/logs/ 'parent_pk'
.After digging in the source code for a reason why there is
parent_pk
, it seems that it is somewhy forced intorelations.py - line 24
. Trying to remove the keyparent_pk
and its corresponding value seems to fix the issue.I'm not sure if I have misconfigured something or if the source code has a bug?