How to use PrimaryKeyRelatedField to update categories on a many-to-many relationship
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Dreaming in Puzzles
--
Chapters
00:00 How To Use Primarykeyrelatedfield To Update Categories On A Many-To-Many Relationship
01:15 Accepted Answer Score 6
01:39 Thank you
--
Full question
https://stackoverflow.com/questions/3080...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #djangorestframework
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Dreaming in Puzzles
--
Chapters
00:00 How To Use Primarykeyrelatedfield To Update Categories On A Many-To-Many Relationship
01:15 Accepted Answer Score 6
01:39 Thank you
--
Full question
https://stackoverflow.com/questions/3080...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #djangorestframework
#avk47
ACCEPTED ANSWER
Score 6
For anyone else having this issue I found a solution that allows PrimaryKeyRelatedField to be read/writeable. Just add queryset
categories = serializers.PrimaryKeyRelatedField(many=True, queryset=Category.objects.all())
It will still filter on the correct relationship which is a bit confusing.