Wednesday, December 1, 2010

list_display with a function

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJM9i6wAAoJEN0tMfpVjIT77woH/jecNwx2ssvQ8iOurRkbuF2l
LEmLYbQnFChkeOBSm5IvAm9QpFGZ8Hdlf6FS83RoGFnU/DaiKhaCZaaPrFwiSQdP
DNzi6HaX1iRyzcOoC2PX/uG6qkWFSYKG+aAyXt5/htOfsQNPA7G6vqHzrMlZnaA5
eWfDMov5B+YEnGwHB3QJbTUB4jE+VngN6CPYj8YhoFHfhPfekPBLcL7Po+CPAzfa
DGECdnar2/VOxWnRvXz8LShX/1EbZS4ZSi6WrMCa4xxYyR+NTaY/YDo0vOH1sz+q
PTsxrbZS7ZoXQLL1gUb3NMSFO7JptHrUIrIkk344N0CnWXxt7p5NlyH8G+uep/4=
=It3o
-----END PGP SIGNATURE-----
hi

I have a model that defines a function:

class Test(models.Model):
name = models.CharField(max_length=200)

data_expira = models.DateField()

def expired(self):
return self.data_expira < datetime.date.today()

expired.short_description = 'Expirou?'


I want to put it in list_display for this model:
list_display = ["name", "expired"]

BUT
django admin displays it as a text, "True" or "False"...

can I tell django that it is a boolean field?

No comments:

Post a Comment