Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#18747 closed Bug (duplicate)

Django admin list_display eats AttributeError by mistake

Reported by: liu.dongyuan@… Owned by: Travis Swicegood
Component: contrib.admin Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

When Django admin list_display calling custom method, the exception AttributeError can't be seen.

See the sample snippets below.

class ExampleAdmin(admin.ModelAdmin):
    def example(self, field):
        raise AttributeError
    list_display = ('example',)
class ExampleAdmin(admin.ModelAdmin):
    def example(self, field):
        a = 1
        a.encode("utf8")
    list_display = ('example',)

Attachments (1)

18747.diff (894 bytes ) - added by thikonom 12 years ago.

Download all attachments as: .zip

Change History (5)

by thikonom, 12 years ago

Attachment: 18747.diff added

comment:1 by thikonom, 12 years ago

Has patch: set
Owner: changed from nobody to thikonom
Status: newassigned

Since i suppose the AttributeError is catched this way by design,
i amended the code to distinguish between the Exception raise by the model itself or by any other object

comment:2 by Travis Swicegood, 12 years ago

Needs tests: set
Owner: changed from thikonom to Travis Swicegood
Patch needs improvement: set
Status: assignednew
Triage Stage: UnreviewedAccepted

Definitely something we should probably handle, though I think there's a better way to figure out where the exception came from. Taking a stab at the patch.

comment:3 by Travis Swicegood, 12 years ago

Resolution: duplicate
Status: newclosed

There are actually a few older versions of this:

Going to close as a duplicate.

comment:4 by Aymeric Augustin, 12 years ago

Fixed in [617d077f].

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