def get_cropduster_field_on_model(model, field_identifier):
    from cropduster.fields import CropDusterField

    opts = model._meta
    if hasattr(opts, 'get_fields'):
        # Django 1.8+
        m2m_fields = [f for f in opts.get_fields() if f.many_to_many and not f.auto_created]
    else:
        m2m_fields = opts.many_to_many
    m2m_related_fields = set(m2m_fields + opts.virtual_fields)

    field_match = lambda f: (isinstance(f, CropDusterField)
        and f.field_identifier == field_identifier)

    try:
        return [f for f in m2m_related_fields if field_match(f)][0]
    except __HOLE__:
        return None
dataset/ETHPy150Open theatlantic/django-cropduster/cropduster/forms.py/get_cropduster_field_on_model