With methods on your model that return boolean values, you can mark them as boolean so the admin's list displays show the pretty icons, like this example from the docs:
class Person(models.Model):
birthday = models.DateField()
def born_in_fifties(self):
return self.birthday.strftime('%Y')[:3] == '195'
born_in_fifties.boolean = True
If a model has a DateTimeField
, then it gets nicely formatted in the list displays.
However, if I've got a method on a model which returns a datetime
, it shows up in list displays with yyyy-mm-dd values (e.g. 2010-03-16), which isn't very nice to read.
Is there some built-in way to mark a method as returning a datetime
, similar to what exists for methods which return booleans?