Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add fallback to Admin log if reverse fails.

  • Loading branch information...
commit f80108fbd3dd498790c5aa9ca0736958f8273dbe 1 parent e298ea7
Michael Kelly authored February 19, 2013

Showing 1 changed file with 8 additions and 5 deletions. Show diff stats Hide diff stats

  1. 13  flicks/base/admin.py
13  flicks/base/admin.py
... ...
@@ -1,6 +1,6 @@
1 1
 from django.contrib import admin
2 2
 from django.contrib.admin.models import LogEntry, DELETION
3  
-from django.core.urlresolvers import reverse
  3
+from django.core.urlresolvers import NoReverseMatch, reverse
4 4
 from django.utils.html import escape
5 5
 
6 6
 from caching.base import CachingQuerySet
@@ -48,10 +48,13 @@ def object_link(self, obj):
48 48
             link = escape(obj.object_repr)
49 49
         else:
50 50
             ct = obj.content_type
51  
-            link = u'<a href="%s">%s</a>' % (
52  
-                reverse('admin:%s_%s_change' % (ct.app_label, ct.model), args=[obj.object_id]),
53  
-                escape(obj.object_repr),
54  
-            )
  51
+            try:
  52
+                link = u'<a href="%s">%s</a>' % (
  53
+                    reverse('admin:%s_%s_change' % (ct.app_label, ct.model),
  54
+                            args=[obj.object_id]),
  55
+                    escape(obj.object_repr))
  56
+            except NoReverseMatch:
  57
+                link = escape(obj.object_repr)
55 58
         return link
56 59
     object_link.allow_tags = True
57 60
     object_link.admin_order_field = 'object_repr'

0 notes on commit f80108f

Please sign in to comment.
Something went wrong with that request. Please try again.