Thank you Massimo.
After your answer I checked the custom auth_table and it turns out
that one of the fields is the issue:
# wrong
Field('age', 'integer', default='')
# right
Field('age', 'string', default='')
# because the validator is: auth_table.age.requires = IS_IN_SET(('',)
+ tuple(range(16,99)))
Thanks again!
On Jul 21, 4:48 pm, mdipierro <[email protected]> wrote:
> I just tried this and I cannot reproduce the problem with this model.
>
> On Jul 21, 8:26 am, Vidul Petrov <[email protected]> wrote:
>
>
>
> > # the action
> > def __insert_default_sm(form):
> > db.some_table.insert(val1=1, val2=2, created_by=form.vars.id)
>
> > auth.settings.register_onaccept = __insert_default_sm
>
> > def user():
> > return dict(form=auth())
>
> > # the model
> > ...
> > # the other auth settings
> > auth.settings.registration_requires_verification = False
> > auth.settings.registration_requires_approval = False
> > ...
> > db.define_table('some_table',
> > Field('val1','integer'),
> > Field('val2','integer'),
> > Field('created_by'),
> > )
>
> > On Jul 21, 4:15 pm, mdipierro <[email protected]> wrote:
>
> > > the error is not in the above code. Can you post the exact model and
> > > action?
>
> > > On Jul 21, 8:09 am, Vidul Petrov <[email protected]> wrote:
>
> > > > Hi all,
>
> > > > I am trying to insert default value in "some_table" for new users:
>
> > > > # init/controllers/default.py
> > > > def __insert_default_val(form):
> > > > db.some_table.insert(val1=1, val2=2, created_by=form.vars.id)
>
> > > > auth.settings.register_onaccept = __insert_default_val
>
> > > > but I get the following exception:
>
> > > > "... sqlhtml.py", line 997, in accepts
> > > > fields[fieldname] = int(fields[fieldname])
> > > > ValueError: invalid literal for int() with base 10: ''
>
> > > > Any ideas for a possible fix?