I'm trying to get my comment page to show the comment author by first and 
last name. Unfortunately I can't get it to display anything but user ID.

My db model:

db.define_table('comments',
    Field('author', db.auth_user, default=auth.user_id, writeable=False),
    Field('postedon', 'date',
        default=request.now, update=request.now, writable=False),
    Field('body', 'text', required=True))


This is my controller:

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


And this is the relevant part of my view:

<div id="comments">
    {{for comment in comments:}}
    <p>{{=comment.body}}</p>
    <p>By {{=comment.author.first_name}} on {{=comment.postedon}}
    {{pass}}
</div>
<div>{{=post}}</div>

When I try to render it I get an error: <type 'exceptions.AttributeError'> 
'NoneType' object has no attribute 'first_name'

I've tried multiple different ways do write this out and all return the 
error ticket. If I remove the first_name reference the page renders fine 
with auth.user_id in the author spot.

-- 



Reply via email to