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
master
branch of Django REST framework.Suppose we have two models,
and to create
Album
instance I have created aAlbumSerializer
and executed the code as
This will return the
PK
ofMusician
s 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 (ofAlbumSerializer
class). 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