Django

Code

Show
Ignore:
Timestamp:
01/12/07 13:40:06 (2 years ago)
Author:
jacob
Message:

Fixed #3287: method columns in the admin changelist can now have a boolean attribute that uses the clever little checkmark icons instead of the ugly "True" or "False" strings. Thanks for the patch, xian@mintchaos.com

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/model-api.txt

    r4276 r4309  
    12681268                  return '<span style="color: #%s;">%s %s</span>' % (self.color_code, self.first_name, self.last_name) 
    12691269              colored_name.allow_tags = True 
     1270 
     1271    * If the string given is a method of the model that returns True or False  
     1272      Django will display a pretty "on" or "off" icon if you give the method a  
     1273      ``boolean`` attribute whose value is ``True``. 
     1274 
     1275      Here's a full example model:: 
     1276 
     1277          class Person(models.Model): 
     1278              first_name = models.CharField(maxlength=50) 
     1279              birthday = models.DateField() 
     1280 
     1281              class Admin: 
     1282                  list_display = ('name', 'born_in_fifties') 
     1283 
     1284              def born_in_fifties(self): 
     1285                  return self.birthday.strftime('%Y')[:3] == 5 
     1286              born_in_fifties.boolean = True 
     1287 
    12701288 
    12711289    * The ``__str__()`` method is just as valid in ``list_display`` as any