This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Nested serializer field required when required = False #2719
Comments
Please send usage questions to the discussion group, IRC or stack overflow. Thanks! :) |
@tomchristie This looks like a bug, |
Having same problem in viewset
keeps saying the fields in created_by are required. |
Hi @tomchristie, just wondering if this will be fixed anytime soon? |
@variable if you need to speed up the process the best way is to help us with a pull request. |
Unclear to me if this is a duplicate of #2919. |
Hi @variable
Could you expand on that? What's the error message, and what code is being run that causes it? |
Probably not a duplicate. First step is to write the most minimal possible failing test case. |
@tomchristie I am not able to reproduce in test case:
The only difference is I am posting via Ajax post, does it make any difference?
|
@tomchristie |
Given this "I am not able to reproduce in test case:" I'm going to assume this was a duplicate of #2919 (just closed now), and close this. More than happy to reconsider if anyone can expand on this with a failing example case. |
I m having exactly the same problem. As mentioned by Anton,
In Address model Street is a required field. I want to have the ship_address to be optional in CustomerSerializer.
Please suggest... |
The discussion group is the best place to take this point and other usage questions. Thanks! |
Looks like this issue was never fixed. Having the same problem as @Anton-Shutik and @sandeepginside and it is not a duplicate of #2919 |
Hi @mihailb. The easiest place to start would be to turn #2719 (comment) into a failing test case/PR. |
Why is this closed? Looks like an important bug to me and can't see any info on that elsewhere. Is there a work around? By using a custom name instead of the model field name and specifying the user_details = UserSerializer(
read_only=True,
source='user',
) instead of user = UserSerializer(
read_only=True,
) which generates a HTTP 400 field required. Note that this prevents the use of the Also, @tomchristie refers this issue in a reply in the mailing list, however no informations help to overcome the problem here. (https://groups.google.com/forum/#!topic/django-rest-framework/ttq8PUAU424) |
Reopening, since @sandeepginside's example should be enough to create a test case. |
Just a hint for some of you experiencing this - I found that in my case it was caused by a unique_together constrain on the model which forced the field at hand to behave as required=True. |
May be this answer solves your problem: |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hi there,
I'm on DRF 3.1.0 and Django 1.7.6 and have serializers like below:
and it works fine when doing like this (usual dict):
BUT it fails when serializer created with request.data in the view, because request.data has MergeDict type
I understand that 'zip' and 'addr1' required fields on Address, but in this case Address is not required at all.
Am I doing smth wrong or any ideas how to fix that ?
Thanks in advance
The text was updated successfully, but these errors were encountered: