| | 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 | |
|---|
| | 1288 | |
|---|