I have a Django Rest Framework set up that serves GET requests properly. After asking a previous question here, it should also be able to update objects properly. However, I'm not sure how I can update just one field in a model object. I have a Model ViewSet like this:
class TaskViewSet(viewsets.ModelViewSet): queryset = Task.objects.filter(done = False).order_by('-unixTime') serializer_class = TaskSerializer paginate_by = None
And I have the urls registered through a router like this:
router = routers.DefaultRouter() router.register(task', views.TaskViewSet) urlpatterns = [ url(r'^', include(router.urls)), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ]
The serializer is about as basic as they come right now:
class TaskSerializer(serializers.ModelSerializer): class Meta: model = Task fields = ('id', 'user', 'task', 'unixTime', 'done')
I'd like to be able to update the 'done' field of the Task object as identified by its primary-key id. I think I would need to use a partial_update model or path, but I'm unsure how to implement this. Also, just to give more information, the DRF browser view says the allowed HTTP methods are
GET, POST, HEAD, OPTIONS.