def create(self, request):
        serializer = self.get_serializer(
            data=request.DATA, files=request.FILES)

        if serializer.is_valid():
            self.pre_save(serializer.object)
            data = serializer.restore_fields(request.DATA, request.FILES)

            task_history = TaskHistory()
            task_history.task_name = "create_database"
            task_history.task_status = task_history.STATUS_PENDING
            task_history.arguments = "Database name: {}".format(data['name'])
            task_history.save()

            result = create_database.delay(name=data['name'],
                                           plan=data['plan'],
                                           environment=data['environment'],
                                           team=data['team'],
                                           project=data['project'],
                                           description=data['description'],
                                           task_history=task_history,
                                           user=request.user)

            headers = self.get_success_headers(data)
            task_url = Site.objects.get_current().domain + \
                '/api/task?task_id=%s' % str(result.id)

            return Response({"task": task_url}, status=status.HTTP_201_CREATED,
                            headers=headers)

        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/api/database.py/DatabaseAPI.create/original