I've setup an edit widget for a field as a relation reference like shown below and save the configuration as a QGIS layer style file (*.qml):
With PyQGIS I do the following steps
- load the vector layer necessary for the relations
- create the relations
- load the style files
But after this, the expression dropdown is empty because it is not stored in the qml file:
<edittype widgetv2type="RelationReference" name="nv_bezeichnung">
<widgetv2config OrderByValue="0" fieldEditable="1" ShowForm="0" Relation="rv-nv" ReadOnly="0" MapIdentification="1" labelOnTop="1" AllowNULL="0"/>
</edittype>
The edit widgets can be configured with PyQGIS like
layer.setEditorWidgetV2Config(fieldId, {'key':'value'})
with keys according to the xml snippet above, but there seems to be no key to store the expression in, therefore my question:
How to store or save the 'Display Expression' in a relation reference or set it up using PyQGIS?