New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to deserialize OneToOneField relationships in DRF>=3.7.0 #27
Comments
Hey! Sorry been out of the loop for a long time but plan on looking into these issues over the next few weeks. Did you solve the problem in the end? |
Hi Ian,
Thanks for getting back to me! We've just held DRF on an earlier version
(3.6.4) for now - haven't worked out a long term fix for it yet.
Christy
…On Fri, 19 Apr 2019, 08:07 Ian Clark, ***@***.***> wrote:
Hey! Sorry been out of the loop for a long time but plan on looking into
these issues over the next few weeks. Did you solve the problem in the end?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABR6ZZCZA25IPWMB4K7GSDPRFVTJANCNFSM4GQZRPEQ>
.
|
OK @c-oreills I've just had a chance to look at this. Thanks for the detailed description, and the minimal repo to reproduce. I forked the repo and had a play. You're right, it does have to do with this issue reported against DRF, essentially they made a change which didn't allow for relational fields to be unmatched. Now, this isn't actually an issue with serializer extensions, simply that by using extensions you always get an ID field serialized by default. I made a serializer within the repo to mimic the extensions behaviour:
Which produces exactly the same error with the DRF version you included in the repo. However, this issue has since been rectified in DRF (confirmed by bumping the version in the POC repo and re-running), and so I'd consider this now a non-issue. Let me know if otherwise. Thanks! |
Hi Ian,
I've run into an issue when upgrading DRF to v3.7.7 due to our use of
expandable_fields
If I have the following code:
Then this test will fail:
with:
If I create a
Child
model and link it toparent
, the test passes.Note that this works in DRF<=3.6.4
I believe this to be due to this commit, which has been linked to this issue and this PR.
We can work around this at other points in our codebase by specifying
default=None
in serializer fields, however this isn't supported in serializer extensions.I've created a repo with a POC here (requirements file has necessary library versions).
I'd appreciate any input on how this could be resolved - one option would be remove from
expandable_fields
and make this a first class field on the serializer but that would require finding all clients which request the expandable field and changing them to no longer ask for it.Thanks very much in advance!
The text was updated successfully, but these errors were encountered: