Opened 4 years ago

Closed 4 years ago

Last modified 4 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 4 years ago.

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by thikonom

Attachment: 18747.diff added

comment:1 Changed 4 years ago by thikonom

Has patch: set
Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to thikonom
Patch needs improvement: unset
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 Changed 4 years ago by Travis Swicegood

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 Changed 4 years ago by Travis Swicegood

Resolution: duplicate
Status: newclosed

There are actually a few older versions of this:

Going to close as a duplicate.

comment:4 Changed 4 years ago by Aymeric Augustin

Fixed in [617d077f].

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