Code

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#283 closed defect (invalid)

templatetags/log.py breaks on AnonymousUser

Reported by: garthk@… Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords: templatetags log anonymous
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by adrian)

Try logging in if you're already the anonymous user. Ouch! Trivial fix:

C:\dev\django-svn\trunk>svn diff
Index: django/templatetags/log.py
===================================================================
--- django/templatetags/log.py  (revision 416)
+++ django/templatetags/log.py  (working copy)
@@ -10,7 +10,10 @@

     def render(self, context):
         if self.user is not None and not self.user.isdigit():
-            self.user = context[self.user].id
+            try:
+                self.user = context[self.user].id
+            except AttributeError: # AnonymousUser doesn't have it
+                pass
         context[self.varname] = log.get_list(user_id__exact=self.user, limit=self.limit, select_related=True)
         return ''

Attachments (0)

Change History (2)

comment:1 Changed 9 years ago by adrian

  • Description modified (diff)

(Fixed formatting in description.)

comment:2 Changed 9 years ago by adrian

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

The admin-log templatetag isn't meant to be used out of the admin context. It's assumed that the user is logged in when the tag is used.

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.