Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#10275 closed (fixed)

Inconsistency between django.contrib.admin.models.LogEntry interface and index.html admin template

Reported by: Jarek Zgoda Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: log
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This inconsistency lies in fact that LogEntry model allows for content_type (and object_id) to be None (both attributes are defined as blank=True, null=True). This causes admin index page failing to render in line 62 of index.html template, which implicitly requires content type to be set: {% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}.

Caught an exception while rendering: Failed lookup for key [name] in u'None'
Original Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/template/debug.py", line 71, in render_node
result = node.render(context)
File "/usr/lib/python2.5/site-packages/django/templatetags/i18n.py", line 42, in render
value = self.value.resolve(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 676, in resolve
value = self._resolve_lookup(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py", line 729, in _resolve_lookup
raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute
VariableDoesNotExist: Failed lookup for key [name] in u'None'

Attachments (1)

10275.patch (3.3 KB) - added by Peter Bengtsson 8 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 8 years ago by Jacob

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Peter Bengtsson

Resolution: fixed
Status: newclosed

Ok. I've changed the template and wrap the entry.content_type.name by first doing a {% if entry.content_type %} so now it's no longer inconsistent.

I've also change the template to not be all on one line but instead multiple lines and indented.
If the HTML has to be completely without whitespace (clearly not a problem in Firefox) it should be wrapped with a spaceless filter or a comment that explains why it can not have whitespace in it.

Attached is a patch plus a patch to the tests which feels a bit bloated but works.

Changed 8 years ago by Peter Bengtsson

Attachment: 10275.patch added

comment:3 Changed 8 years ago by Alex Gaynor

Resolution: fixed
Status: closedreopened

A bug isn't fixed until the code is in the tree.

comment:4 Changed 8 years ago by Matt McClanahan

Has patch: set

comment:5 Changed 8 years ago by Russell Keith-Magee

Resolution: fixed
Status: reopenedclosed

(In [10675]) Fixed #10275 -- Corrected the edge case of rendering a LogEntry with a contenttype of None. Thanks to Jarek Zgoda for the report, and Peter Bengtsson for the patch

comment:6 Changed 8 years ago by Russell Keith-Magee

(In [10676]) [1.0.X] Fixed #10275 -- Corrected the edge case of rendering a LogEntry with a contenttype of None. Thanks to Jarek Zgoda for the report, and Peter Bengtsson for the patch

Merge of r10675 from trunk.

comment:7 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top