datetime.date() is for constructing a date object and it takes integer
arguments (for the year, month, and day) -- you don't pass a date to it.
Instead, just do:
SPAN(v, ...)
Or if you don't like the default format you get when the date is converted
to a string, use the .strftime method:
SPAN(v.strftime('%m/%d/%Y'))
Anthony
On Wednesday, November 11, 2015 at 2:09:04 AM UTC-5, Anthony Smith wrote:
>
> Hi,
> I am using the follow to highlight a date field where the date is greater
> then the current date.
>
> db.stock_task.ESI_withhold_until_date.represent = lambda v,row:
> SPAN(datetime.date(v),_class='withhold' if v >datetime.date.today() else None)
> db.stock_task.ESI_withhold_until_date.represent = lambda v,row:
> SPAN(datetime.date(v),_class='withhold' if v and v> datetime.date.today()
> else None)
>
> Traceback (most recent call last):
> File "/home/tony/web2py/gluon/restricted.py", line 227, in restricted
> exec ccode in environment
> File "/home/tony/web2py/applications/cps5c/controllers/default.py"
> <http://127.0.0.1:8000/admin/default/edit/cps5c/controllers/default.py>, line
> 562, in <module>
> File "applications/cps5c/modules/plugin_sqleditable/editable.py", line 415,
> in extract
> r=func()
> File "/home/tony/web2py/gluon/tools.py", line 3774, in f
> return action(*a, **b)
> File "/home/tony/web2py/applications/cps5c/controllers/default.py"
> <http://127.0.0.1:8000/admin/default/edit/cps5c/controllers/default.py>, line
> 268, in stock_tasks
> db.stock_task.created_by,
> File "/home/tony/web2py/gluon/sqlhtml.py", line 2717, in grid
> nvalue = field.represent(value, row)
> File "/home/tony/web2py/applications/cps5c/models/db1.py"
> <http://127.0.0.1:8000/admin/default/edit/cps5c/models/db1.py>, line 144, in
> <lambda>
> db.stock_task.ESI_withhold_until_date.represent = lambda v,row:
> SPAN(datetime.date (v),_class='withhold' if v > datetime.date.today() else
> None)
> TypeError: an integer is required
>
>
> if I use the following works fine.
> db.stock_task.withhold_until_date.represent = lambda v, row:
> SPAN(prettydate(v),_class='withhold' if v and v>datetime.date.today() else
> None)
>
> any help appreciated
>
> cheers
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.