I want to have multiple users using my app and each content they produce 
will be entitled to their accounts, that way if you make a comment for 
example, your name will be by the comment and if another user should see 
the comment, they'll see your name by the comment. if i can do this, i 
believe i can do it for any other produced content, but here're the code 
snippets followed by the problem I'm facing...

### Model ###

db.define_table('comment',
   Field('content_id', 'reference content'),
   Field('author'),
   Field('body', 'text'))

### Controller ####

def show():
    content = db.content(request.args(0)) or redirect(URL('index'))
    db.comment.content_id.default = content.id
    form = crud.create(db.comment,
               next=URL(args=content.id))
    form.custom.widget.author = auth.user.first_name +' '+ 
auth.user.last_name
    comments = db(db.comment.content_id==content.id).select()
    return dict(content=content, comments=comments, form=form)

### View ###

<h2>Post a comment</h2>
{{=form.custom.begin}}
<div style='float:left;'>Author:</div> <div style="overflow:hidden; 
margin-left:78;">{{=form.custom.widget.author}}</div>
<div style='float:left;'>Comment:</div> <div style="overflow:hidden; 
margin-left:78;">{{=form.custom.widget.body}}</div>
<div style='float:left;'></div> <div style="overflow:hidden; 
margin-left:78;">{{=form.custom.submit}}</div>
{{=form.custom.end}}

Problem: the comment displays None for the author but the comment itself is 
posted though. This line of code is in the models too. 
db.comment.author.writable = False
That way, the author's name can't be altered and is automatically set to 
the currently logged in user's name.

<https://lh4.googleusercontent.com/-ZL1cDigsSlk/UMY-B6puAFI/AAAAAAAAADM/yww7xymjNHg/s1600/Screenshot+from+2012-12-10+16%3A26%3A48.png>

How do I change the "None" to the name of the Author?

-- 



Reply via email to