So I have created a
custom form for my attribute table in QGIS using the
drag and drop designer option. I also have an external
python init function that I imported. Now Let's say I create a new Feature. After I create the feature the custom form pops up and my python file checks if a specific attribute of the feature is not defined(or is NULL). If it is NULL or not defined I set the attribute. My code for this part looks like this:
if feature["name"] is None: feature.setAttribute("name", "Max")
Until now everything works. My problem is now that if I open the attribute table in qgis I always get an KeyError, but the attribute was set successfully. The KeyError look like this
KeyError: 'name'. It might be hard to understand but I can't describe it better. Does anyone know what I am doing wrong?