This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
"'QuerySet' object has no attribute 'pk'" when trying to use 'put' w/ detail=False mapping #6130
Closed
4 of 5 tasks
Checklist
master
branch of Django REST framework.Steps to reproduce
I'm trying to implement a bulk update -- The django rest framework bulk update project seems abandoned, and has a bug that I think is the same as my implementation (I'm trying to do a minimal implementation just for my project and not be dependent on the other one.)
I suspect it's a bug that came up with a recent version of drf3.
The conversation in the bug proposes subclassing the ListSerializer and rewriting
to_internal_value
, copying the code from the original implementation -- inserting this code into the method:The issue comes down to the internals of drf passing the list as the instance in
exclude_current_instance().
Here's how I started implementing mine:
I then implemented
bulk_update
in my viewset - this is just the beginning of it for proof of concept:Stepping over
is_valid()
raises theAttributeError: "'QuerySet' object has no attribute 'pk'"
I'm reluctant to go and just copy a bunch of code from drf into a subclass -- surely it will break in the future.
Expected behavior
I'm hoping there is already a supported way for doing this, and if not, I'm posting this in hope it's a use case you want to consider supporting (not directly the bulk update itself, but the underlying problem of the list serializer) so that bulk updates would be easier to implement outside the project.
Actual behavior
Stepping into
is_valid()
eventually raises theAttributeError: "'QuerySet' object has no attribute 'pk'"
The text was updated successfully, but these errors were encountered: