Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#10275 closed (fixed)

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

Reported by: 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 peterbe 5 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by peterbe

  • Resolution set to fixed
  • Status changed from new to closed

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 5 years ago by peterbe

comment:3 Changed 5 years ago by Alex

  • Resolution fixed deleted
  • Status changed from closed to reopened

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

comment:4 Changed 5 years ago by mattmcc

  • Has patch set

comment:5 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from reopened to closed

(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 5 years ago by russellm

(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 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.