Ticket #3287: admin_boolean_docs.diff

File admin_boolean_docs.diff, 1.1 KB (added by xian@…, 18 years ago)

diff to add boolean=True info to the model creation docs

  • docs/model-api.txt

     
    12681268                  return '<span style="color: #%s;">%s %s</span>' % (self.color_code, self.first_name, self.last_name)
    12691269              colored_name.allow_tags = True
    12701270
     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
    12711289    * The ``__str__()`` method is just as valid in ``list_display`` as any
    12721290      other model method, so it's perfectly OK to do this::
    12731291
Back to Top