<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def handle_class_prepared(sender, **kwargs):
 """ See if this class needs registering of fields """

    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)