Instead of default=auth.user.id, use default=auth.user_id
It is set to None if no user is logged in.

On Mar 28, 1:19 pm, CVstash dot com <[email protected]> wrote:
> Hello, I've constructed a table in the model with an owner field. I
> wish it to always default to the logged in user id being auth.user.id.
>
> I tried setting it as default, as in:
> Field('owner', 'reference auth_user', readable=False, writable=False,
> default=auth.user.id),
>
> problem is logging out would raise the nonetype exception.
>
> If I don't put a default the owner field is not being automatically
> set.
>
> my create() looks like this:
> @auth.requires_login()
> def create():
>      form = crud.create(db.mytable, next = URL('index'))
>      return dict(form=form)
>
> so, any way to set owner to auth.user.id as the object is being
> created?

Reply via email to