Skip to content

Commit

Permalink
Gracefully handle models not registered in admin when rendering
Browse files Browse the repository at this point in the history
papertrail entry admin pages. Bump version to 1.1.6
  • Loading branch information
eranrund committed Nov 28, 2017
1 parent 9e96f68 commit 143ecb8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 1.1.6
------------------------
* Gracefully handle models not registered in admin when rendering papertrail entry admin pages.

Version 1.1.5
------------------------
* Update the `message` field to be a TextField.
Expand Down
2 changes: 1 addition & 1 deletion papertrail/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.1.5'
__version__ = '1.1.6'
default_app_config = 'papertrail.apps.PapertrailConfig'
14 changes: 9 additions & 5 deletions papertrail/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.shortcuts import get_object_or_404, render
from django.urls import NoReverseMatch
from django.utils.encoding import force_text
from django.utils.html import format_html
from django.utils.text import capfirst
Expand Down Expand Up @@ -255,11 +256,14 @@ class EntryRelatedObjectInline(admin.StackedInline):

def related_model(self, obj):
related_obj = obj.related_object
return format_html(
u'<a href="{}">{}</a>',
admin_reverse_for_model(related_obj),
related_obj,
)
try:
return format_html(
u'<a href="{}">{}</a>',
admin_reverse_for_model(related_obj),
related_obj,
)
except NoReverseMatch:
return format_html(u'{}', related_obj)


@admin.register(Entry)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='django-papertrail',
version='1.1.5',
version='1.1.6',
packages=['papertrail'],
install_requires=[
'Django>=1.7',
Expand Down

0 comments on commit 143ecb8

Please sign in to comment.