def get_m2m(parent_model, model):
    # need to check on both sides (m2m field will be defined only in one of the
    # models)
    for rel in parent_model._meta.get_all_related_many_to_many_objects():
        if issubclass(rel.related_model, model):
            return rel.field

    for rel in parent_model._meta.many_to_many:
        if issubclass(rel.related_model, model):
            return rel.field
Presence priority.
dataset/ETHPy150Open allegro/ralph/src/ralph/admin/m2m.py/get_m2m--crossover with--dataset/ETHPy150Open kuri65536/python-for-android/python3-alpha/python-libs/pyxmpp2/presence.py/Presence.priority