-
Notifications
You must be signed in to change notification settings - Fork 301
Issue with relationships in POST/PATCH/PUT requests #122
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
Comments
This behaviour seems to have been introduced in d654c75 |
It looks like this is probably a documentation bug on our part: you need to use |
@martinmaillard, @jerel is right - i introduced ResourceRelatedField to be able to parse things properly: 23d0af6 See issue #111 |
We could also override the |
Ok thank you, I didn't know that :) Now it's working, but I still have an issue with the
|
@martinmaillard I'm open to suggestions and PRs if you find a better way to validate the type as I am going to be busy for some time. The expected type verification is done here: https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/rest_framework_json_api/relations.py#L110 - have fun ;) |
I also think we should create a new issue for the behavior you are describing as it is out of the topic of this one. This issue is a duplicate of #111, I will now close it. |
I will think about it, but it's a complicated issue. These Anyway thank you for your quick answers ! |
No worries - also this issue made us realize we really need to document those features - I'll create a new one for that. |
How the ResourceRelatedField should be used? I still get that the related object is "places" instead of "Place" when creating an object with relation to Place. |
Any update on this? I would say expected type should not be the model name - https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/rest_framework_json_api/relations.py#L119 as everywhere else it's plural lowercase version of it. |
@riklaunim here is an example of the ResourceRelatedField in use: https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/example/serializers.py#L40-L41 If you could create a test that shows the unexpected behavior and open a PR we could discuss it better. |
ok, I missed two things ;)
And it works. |
If I do a POST request with data containing a relationship:
I get the following error:
I understand why this is happening, but I think this is a mistake.
The text was updated successfully, but these errors were encountered: