Permalink
Browse files

Add fallback to Admin log if reverse fails.

  • Loading branch information...
1 parent e298ea7 commit f80108fbd3dd498790c5aa9ca0736958f8273dbe @Osmose Osmose committed Feb 19, 2013
Showing with 8 additions and 5 deletions.
  1. +8 −5 flicks/base/admin.py
View
@@ -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
@@ -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'

0 comments on commit f80108f

Please sign in to comment.