Returns m2m ``field`` as a dict.

    Value is an array of related primary keys and some meta information
    for reconstructing objects.

def _m2m_field_data(field, obj):
    """Returns m2m ``field`` as a dict.

    Value is an array of related primary keys and some meta information
    for reconstructing objects.
    """
    data = _basic_field_data(field, obj)
    data[Field.TYPE] = FieldType.M2M
    related = field.rel.to
    relation_info = {
        Field.REL_DB_TABLE: related._meta.db_table,
        Field.REL_APP: related._meta.app_label,
        Field.REL_MODEL: related.__name__
    }
    data[Field.REL] = relation_info
    value = data[Field.VALUE]
    value = [x[0] for x in value.values_list('pk')]
    data[Field.VALUE] = value
    return data