I have a very simple form processing page in my controller:

def new():
    form = SQLFORM.factory(
        Field('f_name', label='Your name', requires=IS_NOT_EMPTY()),
        )
    if form.process().accepted:
        db.table.insert(**form.vars)
        response.flash = 'form accepted'
    elif form.errors:
        response.flash = 'form has errors'
    else:
        response.flash = 'please fill the form'
    return dict(form=form)

If I leave the form blank, it says there are errors, I fill it in, it says 
the form is accepted. But it fails to update the database, giving this 
error:

<class 'psycopg2.IntegrityError'> null value in column "id" violates 
not-null constraint DETAIL: Failing row contains (null, Boris, T, 
2014-09-23 10:03:30, 11, 2014-09-23 10:03:30, 11). 
What is curious is that I have used this successfully to populate the table:
db.table.insert(f_name='Mary')

I am guessing form.vars includes a value for ID, and Web2Py is trying to 
write this to the database (postgreSQL by the way), rather than allowing 
the database to assign a value, and so the database objects.

Looks like it may be a bug, but I may well be missing something.

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to