I think I have answered myself. This does the job: db.define_table('comments', Field('logged_in_user', 'reference auth_user', default=auth.user_id), Field('user_comment', 'text',requires=IS_NOT_EMPTY()), )
On Monday, September 3, 2018 at 12:02:24 PM UTC-4, 98u...@gmail.com wrote: > > i am getting the error: > <type 'exceptions.AttributeError'> 'NoneType' object has no attribute > 'first_name'..... > Field('logged_in_user', 'string',auth.user.first_name), > AttributeError: 'NoneType' object has no attribute 'first_name' > > > the site is behind the login page and even when I attempt to go the > homepage (can't open the site) I get above error. Because initially no user > is logged in and the table code is executed early on it seems to me. > > the model for component: > > db.define_table('comments', > Field('logged_in_user', 'string', > default=auth.user.first_name), > Field('user_comment', requires=IS_NOT_EMPTY())) > > the controller: > > @auth.requires_login()def manage_comments(): > return SQLFORM.grid(db.comments) > > > This is embedded as text in the text-area field of the markmin wiki: > > @{component:default/manage_comments} > > > Thanks in advance for any assistance! > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.