simple foreign key assignment with serializers #7826
Unanswered
jerinpetergeorge
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checklist
masterbranch of Django REST framework.Suppose we have two models,
and to create
Albuminstance I have created aAlbumSerializerand executed the code as
This will return the
PKofMusicians instance. But, many developers looking for an alternate solution which return a nested serializer response ( related SO post-DRF: Simple foreign key assignment with nested serializers? )So, the common workaround to this problem is overriding the
to_representation(...)method (ofAlbumSerializerclass). But, I there would be a DRF field which takes care of this situation.Something like this will probably suite in the situation
Beta Was this translation helpful? Give feedback.
All reactions