0

我正在使用SimpleKML pip 包能够从我的数据库中的一些线创建 kml 和 kmz 文件

这是我的代码:

@permission_classes(["IsAuthenticated"])
@api_view(['POST'])
def add_cords_to_breach(request):
    data = {}
    if request.method == 'POST':
        # try:
            breach_id = request.data['breach_id']
            breach_object = models.Breach.objects.get(id=breach_id)
            cords = request.data['cords']
            kml = simplekml.Kml()
            for item in cords:
                new_cord = models.BreachCords.objects.create(
                    latlng=item, breach=breach_object)
                theLat = float(item.split(",")[0])
                theLng = float(item.split(",")[1])
                kml.newpoint(name=item.split(",")[0], coords=[(theLat,theLng)])
            print(kml.kml())
            theDIR =os.path.join(BASE_DIR,f'kml_files/')
            kml.save(f'{theDIR}{breach_id}.kml')
            kml.savekmz(f'{theDIR}{breach_id}.kml')
            data = {"success": True, }
            return Response(data, headers=get_headers())

数据正在完美处理,当我使用print(kml.kml())out打印输出时,XML完美打印。但是当谈到储蓄线时,我得到了这个错误

 PermissionError: [Errno 13] Permission denied: '...(full_path_shown_here)../kml_files/253.kml'
4

0 回答 0