İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
5752 Görünümler

def map_field2write(self, field2write):
        res = {}
        field_names = self._get_fieldnames()
        for fn in field2write.keys():
            if fn not in field_names:
               continue
            else:
               res[field_names[fn]] = field2write[fn]
        return res


what is the error?



Avatar
Vazgeç
Üretici

I tried if condition, but still error.

En İyi Yanıt

Error clearly says field2write 'bool' object has no attribute 'keys'
To avoid check is fiel2write contain value and type dict then other line code execute

Example:

Check

if field2write:

    for fn in field2write.keys():

Avatar
Vazgeç
En İyi Yanıt

Hi,

You can try update the method as below

def map_field2write(self, field2write):
res = {}
if not field2write:
return res
field_names = self._get_fieldnames()
for fn in field2write.keys():
if fn not in field_names:
continue
else:
res[field_names[fn]] = field2write[fn]

return res

Regards

Avatar
Vazgeç