diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5164c05..1d9a228 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Current * Add tests and support for Django 1.9 and Python 3.5. * Drop support for Python 2.5, 2.6, Django 1.4, 1.5, 1.6. * Test with py.test instead of unittest. +* Fix AttributeError when content_type is None. v0.1.5 - 17/02/2015 diff --git a/logentry_admin/admin.py b/logentry_admin/admin.py index c4dd346..dd023cb 100644 --- a/logentry_admin/admin.py +++ b/logentry_admin/admin.py @@ -108,13 +108,14 @@ def has_delete_permission(self, request, obj=None): def object_link(self, obj): object_link = escape(obj.object_repr) + content_type = obj.content_type - if obj.action_flag != DELETION: + if obj.action_flag != DELETION and content_type is not None: # try returning an actual link instead of object repr string try: url = reverse( - 'admin:{}_{}_change'.format(obj.content_type.app_label, - obj.content_type.model), + 'admin:{}_{}_change'.format(content_type.app_label, + content_type.model), args=[obj.object_id] ) object_link = '{}'.format(url, object_link)