def value_from_document(instance, field_name):

    field_type = get_field_type_from_document(instance, field_name)

    # Refactor this into a class for each data type.
    if field_type in [list, dict]:
        return json.dumps(instance[field_name])

    return instance[field_name]
dataset/ETHPy150Open peterbe/django-mongokit/django_mongokit/forms/forms.py/value_from_document/original