

def _introspect_inline_admin(self, inline):
    'Introspects the given inline admin, returning a tuple of (inline_model, follow_field).'
    inline_model = None
    follow_field = None
    fk_name = None
    if issubclass(inline, GenericInlineModelAdmin):
        inline_model = inline.model
        ct_field = inline.ct_field
        fk_name = inline.ct_fk_field
        for field in self.model._meta.virtual_fields:
            if (isinstance(field, GenericRelation) and (remote_model(field) == inline_model) and (field.object_id_field_name == fk_name) and (field.content_type_field_name == ct_field)):
                follow_field = field.name
                break
    elif issubclass(inline, options.InlineModelAdmin):
        inline_model = inline.model
        fk_name = inline.fk_name
        if (not fk_name):
            for field in inline_model._meta.fields:
                if (isinstance(field, (models.ForeignKey, models.OneToOneField)) and issubclass(self.model, remote_model(field))):
                    fk_name = field.name
                    break
        if (fk_name and (not remote_field(inline_model._meta.get_field(fk_name)).is_hidden())):
            field = inline_model._meta.get_field(fk_name)
            accessor = remote_field(field).get_accessor_name()
            follow_field = accessor
    return (inline_model, follow_field, fk_name)

dataset/ETHPy150Open etianen/django-reversion/src/reversion/admin.py VersionAdmin._introspect_inline_admin/original