-
Notifications
You must be signed in to change notification settings - Fork 106
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
PUT/PATCH support is broken #51
Comments
maybe also caused by the confusing readme, like #55? |
Edit: my problem was unrelated. DRF-bulk doesn't seem to work with a hyperlinked API out of the box, this was the cause. Original post quoted below.
|
The data for each instance that should be updated must be a separate json
# prepare a dict payload for each object
data = [{
'id': id__,
'value': 10000
} for id__ in id_filter] However, an empty |
I've tried creating a very simple API endpoint following the README:
I've configured a URL for
FooView
and am able to load the built inrest_framework
html page for this API endpoint. I've also created a few instances of theFoo
model for testing.However, when I attempt to make an HTTP PUT/PATCH request to this endpoint to update one of the existing instances, I get a successful return code but no update actually occurs.
curl 'http://127.0.0.1:8000/foo/' -X PUT -H 'Cookie: csrftoken=M8jkbJtUKwjKB7zya8JYvxqJVxkRaPgG' -H 'X-CSRFToken: M8jkbJtUKwjKB7zya8JYvxqJVxkRaPgG' --data 'id=1&name=D' --compressed
The response is simply an empty list
[]
and the instance with id=1 retains its old name.I've created a sample project to reproduce this, and would really appreciate any help. I am unable to determine if this is a bug in DRF, DRF-bulk, or a misunderstanding on my part.
[Update]
I tried testing a POST request, like so, and it did create a new object:
curl 'http://127.0.0.1:8000/foo/' -X POST -H 'Cookie: csrftoken=M8jkbJtUKwjKB7zya8JYvxqJVxkRaPgG' -H 'X-CSRFToken: M8jkbJtUKwjKB7zya8JYvxqJVxkRaPgG' --data 'name=D' --compressed
The response for this request is:
{"id":4,"name":"D"}
However, trying to create a new object with PUT does not work:
curl 'http://127.0.0.1:8000/foo/' -X PUT -H 'Cookie: csrftoken=M8jkbJtUKwjKB7zya8JYvxqJVxkRaPgG' -H 'X-CSRFToken: M8jkbJtUKwjKB7zya8JYvxqJVxkRaPgG' --data 'name=E'
The response for this is:
[]
I believe that PUT/PATCH support for django_rest_framework-bulk is broken at this point. Python package info is:
The text was updated successfully, but these errors were encountered: