I changed date to datetime in my comments database model and now after 
submitting a comment I can't load the comment function.

I figured I just broke the database with the switch and tried to wipe it to 
start over. That didn't work though. In appadmin if I go to the comments 
table I get the same error and it shows zero rows. I tried just wiping the 
sqlite database off the disk and letting web2py write a new one but for 
some reason that doesn't solve the problem either.

Model:
db.define_table('comments',
    Field('author', db.auth_user, default=auth.user_id),
    Field('postedon', 'datetime', default=request.now),
    Field('body', 'text', required=True))

Controller:
def index():
    images = db().select(db.photos.ALL)
    comments = db().select(db.comments.ALL, orderby=~comments.postedon)
    post = crud.create(db.comments)
    return dict(images=images, comments=comments, post=post)

View:
<center>
<div id="comments">
    {{for comment in comments:}}
        <hr />
        <p>{{=MARKMIN(comment.body)}}</p>
    <p><em><small>By {{=comment.author.first_name}} 
{{=comment.author.last_name}} on {{=comment.postedon.strftime("%B %e, %Y")}}
</small></em></p>
    {{pass}}
<p>Leave a comment:</p>
<div>{{=post}}</div></div></center>

Error:
<type 'exceptions.ValueError'> invalid literal for int() with base 10: '06 
21:12:04'

If I switch the postedon field back to 'date' instead of 'datetime' it 
works fine. Am I just using datetime improperly?


-- 



Reply via email to