def handle_class_prepared(sender, **kwargs):
    from .settings import M2M_REGISTRY, FK_REGISTRY
    from .registration import registry
    sender_app = sender._meta.app_label
    sender_name = sender._meta.model_name

    for key, val in list(FK_REGISTRY.items()):
        app_name, model_name = key.split('.')
        if app_name == sender_app and sender_name == model_name:
            registry.register_model(app_name, sender, 'ForeignKey', val)

    for key, val in list(M2M_REGISTRY.items()):
        app_name, model_name = key.split('.')
        if app_name == sender_app and sender_name == model_name:
            registry.register_model(app_name, sender, 'ManyToManyField', val)
Handle a <field> node for a ManyToManyField.
dataset/ETHPy150Open callowayproject/django-categories/categories/apps.py/handle_class_prepared--crossover with--dataset/ETHPy150Open dcramer/django-compositepks/django/core/serializers/xml_serializer.py/Deserializer._handle_m2m_field_node