please try: db.Register.repliedOn.represent = lambda v, row: v.strftime('%d/%m/%Y %H:%M:%S') if v else ""
Il giorno sabato 19 maggio 2012 09:00:37 UTC+2, Annet ha scritto: > > In a model I have the following validator: > > db.Register.repliedOn.requires=IS_EMPTY_OR(IS_DATETIME(format='%Y-%m-%d > %H:%M:%S')) > db.Register.repliedOn.represent = lambda v, row: v.strftime('%d/%m/%Y > %H:%M:%S') > > When repliedOn is empty I get the following error: > > File > "/Library/Python/2.5/site-packages/web2py/applications/bootstrap/models/10_table_db.py" > <http://127.0.0.1:8000/admin/default/edit/bootstrap/models/10_table_db.py>, > line 389, in <lambda> > db.Register.repliedOn.represent = lambda v, row: v.strftime('%d/%m/%Y > %H:%M:%S') > AttributeError: 'NoneType' object has no attribute 'strftime' > > > Is there a way to make represent conditional? > > > Kind regards, > > Annet >