def post(self, request, format=None): data = [] for file in request.FILES.getlist("files[]"): obj = Image(car=None, status="D", created_by=request.user) obj.image.save(file.name, file) obj.save() file_name, file_ext = os.path.splitext(file.name.rpartition("/")[-1]) data.append( { "name": file.name, "size": file.size, "url": settings.MEDIA_URL + "cars/full/" + file.name, "thumbnail_url": obj.thumbnail_by_size(100, 100), "delete_url": "/vehicle/api/image.json?id=%s" % obj.id, "delete_type": "DELETE", "image_id": obj.id, } ) response = Response(data) response["Content-Disposition"] = "inline; filename=files.json" return response