id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 26085 contenttypes.views.shortcut fails if a FK to Site returns None Jaap Roes Fabien Schwob "The `contenttypes.views.shortcut` assumes that a FK to Site is never nullable. Causing it to raise an `AttributeError` when the field actually is null. This is happens e.g. when clicking the ""view on site"" link in the admin on an object that has an empty Site relation. {{{ # Next, look for a many-to-one relationship to Site. if object_domain is None: for field in obj._meta.fields: if field.rel and field.rel.to is Site: try: object_domain = getattr(obj, field.name).domain except Site.DoesNotExist: pass }}} Either explicitly checking that the result of the `getattr` call is not `None` or catching a `AttributeError` will fix this." Bug closed contrib.contenttypes dev Normal fixed dani poni Ready for checkin 1 0 0 0 1 0