def put(self, request, id, format=None): ProfileTemplate=self.get_object(id) ProfileTemplate.config_path.delete(save=False) file_obj = request.FILES['file'] ProfileTemplate.config_path = file_obj file_content = file_obj.read() params = parse_file(file_content) ProfileTemplate.parameters = json.dumps(params) logger.debug("File content: "+str(file_content)) ProfileTemplate.save() logger.debug("File named %s saved in db" % (file_obj)) resp = {} resp['message'] = "File updated successfully." serializer = ProfileTemplateSerializer(ProfileTemplate) return Response(serializer.data)
def delete(self, request, id, format=None): ProfileTemplate = self.get_object(id) ProfileTemplate.delete() logger.debug("Profile Template record deleted successfully for id :"+str(id)) return Response(status=status.HTTP_204_NO_CONTENT)