Field("the_date",
                               requires=IS_EMPTY_OR(IS_DATE()),
                               widget=SQLFORM.widgets.date.widget),

should be 

                       Field('the_date',type='date')

the requires and the widget are default.

On Wednesday, 9 October 2013 13:41:11 UTC-5, Ryan Matlock wrote:
>
> I'm pretty new to web2py, so I'm probably making a silly mistake.  In any 
> case, the error goes something like this:
>
> In db.py, I have something like
>
> db.define_table("my_table",
>                        Field("name"),
>                        Field("the_date",
>                                requires=IS_EMPTY_OR(IS_DATE()),
>                                widget=SQLFORM.widgets.date.widget),
>                        format = "%(name)s")
>
> Then I go to the appadmin and pick a date using the widget, and end up 
> with something like "2013-10-09".  When I submit it, I get an internal 
> error, and it seems that the relevant parts of the ticket are the following:
>
> Traceback (most recent call last):
>   File 
> "/Applications/web2py/web2py.app/Contents/Resources/gluon/restricted.py", 
> line 217, in restricted
>   File 
> "/Applications/web2py/web2py.app/Contents/Resources/applications/service/views/appadmin.html",
>  
> line 189, in <module>
>   File 
> "/Applications/web2py/web2py.app/Contents/Resources/gluon/sqlhtml.py", line 
> 2924, in __init__
>   File "/Applications/web2py/web2py.app/Contents/Resources/gluon/dal.py", 
> line 9641, in formatter
>   File 
> "/Applications/web2py/web2py.app/Contents/Resources/gluon/validators.py", 
> line 2701, in formatter
>   File 
> "/Applications/web2py/web2py.app/Contents/Resources/gluon/validators.py", 
> line 2277, in formatter
> AttributeError: 'str' object has no attribute 'year'
> Error snapshot  help
> <type 'exceptions.AttributeError'>('str' object has no attribute 'year')
>
> and 
>
> Function argument list
>
> (self=<gluon.validators.IS_DATE object>, value='2013-10-09')
>
> I'm a little confused as to why the validator is confused by a date 
> properly formatted by the date widget.  When I comment out the 
> "requires=IS_EMPTY_OR(IS_DATE())" line in my db.py file, the error goes 
> away.
>

-- 
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/groups/opt_out.

Reply via email to