2015-11-11 44 views
0

我正在使用以下來突出顯示日期字段,其中日期大於當前日期。web2py,TypeError:需要一個整數

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) 

    db.stock_task.withhold_until_date.represent = lambda v, row: 
    SPAN(prettydate(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", 
     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", l 
     ine 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", 
     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 

如果我使用它的工作原理以下罰款。

db.stock_task.withhold_until_date.represent = lambda v, row: 
    SPAN(prettydate(v),_class='withhold' if v and v>datetime.date.today() 
    else None) 

任何幫助讚賞

歡呼

+0

我認爲「別人無」您正在使用可能會崩潰,請嘗試例如返回0代替。 – Netwave

+0

同樣的結果,我認爲這是在控制器somtething,但無法制定出什麼 – user3502263

+0

db.stock_task.ESI_withhold_until_date.represent = lambda v, row:SPAN(v,_class ='prehold'if v> datetime.date.today ()否)無) – user3502263

回答

0
db.stock_task.ESI_withhold_until_date.represent = lambda v, row: SPAN(v,_class='withhold' if v > datetime.date.today()else None) 
相關問題