Index: django/contrib/admin/templates/admin/index.html
===================================================================
--- django/contrib/admin/templates/admin/index.html (revision 10282)
+++ django/contrib/admin/templates/admin/index.html (working copy)
@@ -59,7 +59,15 @@
{% else %}
{% for entry in admin_log %}
- - {% if not entry.is_deletion %}{% endif %}{{ entry.object_repr }}{% if not entry.is_deletion %}{% endif %}
{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}
+ -
+ {% if entry.is_deletion %}
+ {{ entry.object_repr }}
+ {% else %}
+ {{ entry.object_repr }}
+ {% endif %}
+
+ {% if entry.content_type %}{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}{% endif %}
+
{% endfor %}
{% endif %}
Index: tests/regressiontests/admin_views/tests.py
===================================================================
--- tests/regressiontests/admin_views/tests.py (revision 10282)
+++ tests/regressiontests/admin_views/tests.py (working copy)
@@ -526,6 +526,27 @@
response = self.client.get('/test_admin/admin/')
should_contain = """%s""" % (quote(self.pk), escape(self.pk))
self.assertContains(response, should_contain)
+
+ def test_recentactions_without_content_type(self):
+ """If an LogEntry is missing content_type (ie. content_type = NULL) it
+ will not display it in span tag under the hyperlink."""
+ response = self.client.get('/test_admin/admin/')
+ should_contain = """%s""" % (quote(self.pk), escape(self.pk))
+ self.assertContains(response, should_contain)
+ should_contain = "Model with string primary key" # capitalized in Recent Actions
+ self.assertContains(response, should_contain)
+ logentry = LogEntry.objects.get(content_type__name__iexact=should_contain)
+ # http://code.djangoproject.com/ticket/10275
+ # if the log entry doesn't have a content type it should still be
+ # possible to view the Recent Actions part
+ logentry.content_type = None
+ logentry.save()
+
+ counted_presence_before = response.content.count(should_contain)
+ response = self.client.get('/test_admin/admin/')
+ counted_presence_after = response.content.count(should_contain)
+ self.assertEquals(counted_presence_before - 1,
+ counted_presence_after)
def test_deleteconfirmation_link(self):
"The link from the delete confirmation page referring back to the changeform of the object should be quoted"