Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32792 closed Bug (duplicate)

admin.display decorator boolean flag not working with @property

Reported by: Ronny Vedrilla Owned by: nobody
Component: contrib.admin Version: 3.2
Severity: Normal Keywords:
Cc: pope1ni Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi guys,

I really hope that I'm not missing anything.

I have a model with a boolean property I'd like to show in my admin list view:

class MyModel(models.Model):
    ....

    @property
    @admin.display(description=_('Is external'), boolean=True)
    def is_external(self):
        return bool(self.requested_external)

My admin column shows True and False strings instead of the green and red icons.

When I remove the property decorator, it works as expected.

I double-checked the docs but couldn't find any note about not using it with properties.

Thanks!

Attachments (1)

admin_column.png (7.9 KB ) - added by Ronny Vedrilla 3 years ago.

Download all attachments as: .zip

Change History (3)

by Ronny Vedrilla, 3 years ago

Attachment: admin_column.png added

comment:1 by Mariusz Felisiak, 3 years ago

Cc: pope1ni added
Resolution: duplicate
Status: newclosed

Yes, boolean doesn't work for properties. It's a duplicate of #31558.

comment:2 by Ronny Vedrilla, 3 years ago

Ok, I searched the database for django 3.2 issues (because the decorator was added there - thats why I didnt find it. Sorry.

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