On 16 April 2012 10:25, Annet <[email protected]> wrote:

> In db.py I defined a table:
>
> db.define_table('Node',
>     Field('createdOn',type='datetime',writable=False,readable=False),
>     migrate=False)
>
> db.Node.createdOn.default=request.now
> db.Node.createdOn.requires=IS_DATETIME(str(T('%Y-%m-%d %H:%M:%S')))
>
> Now, when I add this validator:
>
> db.Node.createdOn.represent = lambda v: v.strftime('%d/%m/%Y')
>

Try:

db.Node.createdOn.represent = lambda
db.mytable.name.represent = lambda v, row: v.strftime('%d/%m/%Y')


See the examples in the book:


   - represent can be None or can point to a function that takes a field
   value and returns an alternate representation for the field value.
   Examples:

1.
2.
3.
4.

db.mytable.name.represent = lambda name,row: name.capitalize()
db.mytable.other_id.represent = lambda id,row: row.myfield
db.mytable.some_uploadfield.represent = lambda value,row: \
    A('get it', _href=URL('download', args=value))


Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Reply via email to