def METHOD_NAME(apps, schema_editor=None):
    dlanguage_model = apps.get_model("models", "DLanguage")
    language_model = apps.get_model("models", "Language")
    d_languages = dlanguage_model.objects.all()
    for lang in d_languages:
        language_row = language_model.objects.filter(code__iexact=str.lower(lang.languageid)).first()
        if language_row:
            language_row.isdefault = lang.isdefault
            language_row.save()
        else:
            try:
                language_info = translation.get_language_info(lang.languageid)
            except KeyError:
                language_info = None
            if language_info:
                language_model.objects.create(
                    code=lang.languageid,
                    name=language_info["name"],
                    default_direction="rtl" if language_info["bidi"] else "ltr",
                    isdefault=lang.isdefault,
                )
            else:
                language_model.objects.create(
                    code=lang.languageid, name=lang.languagename.title(), default_direction="ltr", isdefault=lang.isdefault
                )