def introspect_many_to_many_relations(through):
    """
    helper to introspect a through model and return all usefull data like the many2many fields,
    the fk and the related models.
    return a list of 2 items: one for each «side» of the many2many.
    each items contains a n3 tuple: the through.foreignkey, the related model, and the ManytoMany(Rel].
    """
    fields = []
    for fk in through._meta.get_fields():
        if fk.is_relation and fk.many_to_one:
            for rel_model_f in fk.rel.model._meta.get_fields():
                if (rel_model_f.is_relation and rel_model_f.many_to_many and
                    getattr(rel_model_f, 'rel', rel_model_f).through == through
                    ):
                    fields.append((fk, fk.rel.model, rel_model_f))
                    break
            else:
                raise AssertionError(
                    "we can't find the field used as relation using through %s"
                     % through)
    return fields
