list_display – boolean icons for methods

This is documented, although it’s a bit hard to find – go a couple of screens down from here, and you’ll find this:

If the string given is a method of the model, ModelAdmin or a callable that returns True or False Django will display a pretty “on” or “off” icon if you give the method a boolean attribute whose value is True.

and the example given is:

def born_in_fifties(self):
    return self.birthday.strftime('%Y')[:3] == '195'
born_in_fifties.boolean = True

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)