Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
Add fallback to Admin log if reverse fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Kelly committed Feb 19, 2013
1 parent e298ea7 commit f80108f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions flicks/base/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
from django.contrib.admin.models import LogEntry, DELETION
from django.core.urlresolvers import reverse
from django.core.urlresolvers import NoReverseMatch, reverse
from django.utils.html import escape

from caching.base import CachingQuerySet
Expand Down Expand Up @@ -48,10 +48,13 @@ def object_link(self, obj):
link = escape(obj.object_repr)
else:
ct = obj.content_type
link = u'<a href="%s">%s</a>' % (
reverse('admin:%s_%s_change' % (ct.app_label, ct.model), args=[obj.object_id]),
escape(obj.object_repr),
)
try:
link = u'<a href="%s">%s</a>' % (
reverse('admin:%s_%s_change' % (ct.app_label, ct.model),
args=[obj.object_id]),
escape(obj.object_repr))
except NoReverseMatch:
link = escape(obj.object_repr)
return link
object_link.allow_tags = True
object_link.admin_order_field = 'object_repr'
Expand Down

0 comments on commit f80108f

Please sign in to comment.