def update(self, request, *args, **kwargs):
        if not self.has_model() or not self.has_form():
            return rc.NOT_IMPLEMENTED

        pkfield = kwargs.get(self.model._meta.pk.name) or request.data.get(
            self.model._meta.pk.name)

        if not pkfield or request.data is None:
            return rc.BAD_REQUEST

        try:
            obj = self.model.objects.get(pk=pkfield)
        except __HOLE__:
            return rc.NOT_FOUND

        if not self.check_instance_permission(request, obj, "w"):
            return rc.FORBIDDEN

        attrs = self.flatten_dict(request)

        form = self.form(instance=obj, **attrs)
        if form.is_valid():
            obj = form.save()
            return obj
        else:
            self.status = 400
            return form.errors
dataset/ETHPy150Open treeio/treeio/treeio/core/api/handlers.py/ObjectHandler.update