'Given a model and its model def (a dict of field: triple), returns three
items: the real fields dict, the Meta dict, and the M2M fields dict.'

def split_model_def(self, model, model_def):

    real_fields = SortedDict()
    meta = SortedDict()
    m2m_fields = SortedDict()
    for (name, triple) in model_def.items():
        if (name == 'Meta'):
            meta = triple
        elif isinstance(model._meta.get_field_by_name(name)[0], models.ManyToManyField):
            m2m_fields[name] = triple
        else:
            real_fields[name] = triple
    return (real_fields, meta, m2m_fields)
