Fixed #23444 -- Prevented unnecessary ContentType object creation when using inlines

ContentType object is mistakenly created for `through` model of M2M relation when it is used in inline.
You could write this `try...except` as

```py
with self.assertRaises(AttributeError):
    iaf.original_content_type_id
```