def get_translatableobject_content_type()

in testapp/factories.py [0:0]


def get_translatableobject_content_type(obj: TranslatableMixin) -> ContentType:
    for cls in type(obj).mro():
        if issubclass(cls, models.Model):
            for field in cls._meta.get_fields(include_parents=False):
                if field.name == "translation_key":
                    return ContentType.objects.get_for_model(cls)
    raise ValueError("obj must be a TranslatableMixin instance")