Find all fields and return them as a dictionary.

    note:: this function is copied and modified
        from django.forms.get_declared_fields

def get_declared_fields(bases, attrs):
    """ Find all fields and return them as a dictionary.

    note:: this function is copied and modified
        from django.forms.get_declared_fields
    """

    def is_field(prop):
        return isinstance(prop, forms.Field) or \
            isinstance(prop, BaseRepresentation)

    fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if is_field(obj)]
    # add fields from base classes:
    for base in bases[::-1]:
        if hasattr(base, 'base_fields'):
            fields = base.base_fields.items() + fields
    return dict(fields)