def as_serialised_field(field, form):
    if isinstance(field, FormElement):
        return field.as_dict(form)
    else:
        data = field.getattrs(form)
        data['name'] = field.html_name()
        if form.is_bound:
            pass
        elif field.name in form.initial:
            data['value'] = form.initial[field.name]
        for name in tuple(data):
            if name.startswith('data_'):
                value = data.pop(name)
                data[name.replace('_', '-')] = value
        return {'field': data}
dataset/ETHPy150Open quantmind/lux/lux/forms/serialise.py/as_serialised_field/original