Updating Model with ModelViewSet?

437 views
Skip to first unread message

Michael Marshall

unread,
Apr 22, 2015, 2:45:34 PM4/22/15
to django-res...@googlegroups.com
I'm trying to figure out how to update a model when its view is a ModelViewSet. When I post to its url, I can create an instance, but if I want to update an instance, what do I do? Specify a "put" command?

In Views.py:

class BuyerProfileViewSet(viewsets.ModelViewSet):
   
"""
    API endpoint that allows users to be viewed or edited.
    """

    queryset
= BuyerProfile.objects.all()
    serializer_class
= BuyerProfileSerializer

Joseph Wayodi

unread,
Apr 25, 2015, 6:51:48 PM4/25/15
to django-res...@googlegroups.com
Yes, make a PUT or PATCH (for partial updates) request to the URL of a
particular resource (e.g.
<http://localhost:8000/api/buyer-profiles/1/>).
Reply all
Reply to author
Forward
0 new messages