OK, that solved it.

I changed the name of the Field and now everything is OK. I assume SQLite
is ignoring the old field.

Thanks
Simon

On 19 August 2012 21:15, Massimo Di Pierro <[email protected]>wrote:

> Cannot reproduce. Which web2py version?
>
>
> On Sunday, 19 August 2012 15:04:58 UTC-5, Simon Carr wrote:
>>
>> I am trying to use a datetime type in my database. I have the following
>> table definition.
>>
>> db.define_table(
>> 'post',
>> Field('author',db.auth_user),
>> Field('PostDate','datetime',**requires=IS_DATETIME(format='%**d/%m/%Y
>> %H:%M:%S'),default=request.**now),
>> Field('title',requires=IS_NOT_**EMPTY()),
>> Field('body','text',requires=**IS_NOT_EMPTY()),
>> format='%(title)s')
>>
>> When I try to fill in a form, I get the correct calendar format but when
>> I submit the form I get an error (See below). If I use just the date format
>> all is well and I can create new posts. What am I doing wrong?
>>
>> Simon
>>
>>
>>
>> TRACEBACK
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>> 21.
>> 22.
>> 23.
>> 24.
>> 25.
>> 26.
>>
>> Traceback (most recent call last):
>>
>>   File "/home/simon/web2py/gluon/**restricted.py", line 205, in restricted
>>
>>     exec ccode in environment
>>   File "/home/simon/web2py/**applications/blog/controllers/**post.py" 
>> <http://localhost:8000/admin/default/edit/blog/controllers/post.py>, line 
>> 18, in <module>
>>
>>   File "/home/simon/web2py/gluon/**globals.py", line 173, in <lambda>
>>
>>     self._caller = lambda f: f()
>>
>>   File "/home/simon/web2py/gluon/**tools.py", line 2575, in f
>>
>>     return action(*a, **b)
>>
>>   File "/home/simon/web2py/**applications/blog/controllers/**post.py" 
>> <http://localhost:8000/admin/default/edit/blog/controllers/post.py>, line 
>> 12, in new_post
>>
>>     posts = get_posts()
>>   File "/home/simon/web2py/**applications/blog/controllers/**post.py" 
>> <http://localhost:8000/admin/default/edit/blog/controllers/post.py>, line 
>> 16, in get_posts
>>
>>     return db().select(db.post.ALL)
>>
>>   File "/home/simon/web2py/gluon/dal.**py", line 7578, in select
>>
>>     return adapter.select(self.query,fiel**ds,attributes)
>>
>>   File "/home/simon/web2py/gluon/dal.**py", line 1315, in select
>>
>>     rows = response(sql)
>>
>>   File "/home/simon/web2py/gluon/dal.**py", line 1305, in response
>>
>>     self.execute(sql)
>>
>>   File "/home/simon/web2py/gluon/dal.**py", line 1392, in execute
>>
>>     return self.log_execute(*a, **b)
>>
>>   File "/home/simon/web2py/gluon/dal.**py", line 1386, in log_execute
>>
>>     ret = self.cursor.execute(*a, **b)
>>
>>   File "/usr/lib/python2.7/sqlite3/**dbapi2.py", line 63, in convert_date
>>
>>     return datetime.date(*map(int, val.split("-")))
>> ValueError: invalid literal for int() with base 10: '19 21:00:28'
>>
>>  IN FILE: /HOME/SIMON/WEB2PY/**APPLICATIONS/BLOG/CONTROLLERS/**POST.PY
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>>
>> # coding: utf8
>> # try something like
>> def index():
>>
>>     posts = db().select(db.post.ALL)
>>
>>     return dict(title="Blog Posts",posts=posts)
>>
>> @auth.requires_login()
>> def new_post():
>>
>>     form = SQLFORM 
>> <http://localhost:8000/examples/global/vars/SQLFORM>(db.post)
>>
>>     if form.process().accepted:
>>
>>         response <http://localhost:8000/examples/global/vars/response>.flash 
>> = "New post saved"
>>
>>     posts = get_posts()
>>     return dict(posts=posts,form=form)
>>
>> def get_posts():
>>     return db().select(db.post.ALL)
>>
>> response 
>> <http://localhost:8000/examples/global/vars/response>._vars=response 
>> <http://localhost:8000/examples/global/vars/response>._**caller(new_post)
>>
>>  --
>
>
>
>

-- 



Reply via email to