RetrieveUpdateDestroy how works

Screenshot_6


it works on the course drf!but i confused how. by logic i would add to filter like pk = self.kwargs[‘pk’] but it works and send only that ‘id=pk’ post.Can u explain why

U r asking about filtering. So u don’t have to use any self.kwargs. And specially pk. In this case pk is owned by Todo object not user. Of course u could use such filtering:
Todo.objects.filter(user_id=user.id)
but the same effect has got syntax with user object. It’s because object user (made by Foreign Key) is a part of Todo model (I hope I’m clear). Take a look how Todo model looks like:


as u can see there is user object which could be filtered. Finally SQL query is using only user_id:
SELECT "todo_todo"."id", "todo_todo"."title", "todo_todo"."memo", "todo_todo"."created", "todo_todo"."datecompleted", "todo_todo"."important", "todo_todo"."user_id" FROM "todo_todo" WHERE "todo_todo"."user_id" = 1

Great answer @croolic, did that help @tdimasg?