I have a different problem with similar table/field. I have a reference to auth_user. But I want the table to work even it doesn't assign any user. But if I don't pick any auth_user from the drop down menu (assign to) I get an error (attached), value not in a database. And I get the error even when I delete:
requires=IS_IN_DB(db,db.auth_user.id) Here is my table. import os db.define_table("Project", Field("Title", "string", label='Project Title', requires=IS_NOT_EMPTY(),default=None), Field("filename", "upload", default=None, uploadfolder=os.path.join(request.folder, 'uploads')), Field("Description", "text", label='Project Description', requires=IS_NOT_EMPTY(),default=None), Field("Project_budget", "integer", label='Project Budget $', default=None), Field("start_date", "datetime", default=request.now, readable = False, writable=False), Field("finish_date", "datetime", label='Project Due Date', default=None), Field("asigned_to",'reference auth_user', widget=SQLFORM.widgets.options.widget, requires=IS_IN_DB(db,db.auth_user.id)), auth.signature) Any thoughts? On Monday, January 18, 2016 at 2:52:58 PM UTC-5, Richard wrote: > > You should use field .clone() method instead of redefining fields... > > For represent the user_id by it username, you should specify the represent > field like this in your IS_IN_DB() validator : > > IS_IN_DB(db,db.auth_user.id, '%(username)s') > > Richard > > On Wed, Jan 13, 2016 at 7:36 PM, Tom Campbell <tomca...@gmail.com > <javascript:>> wrote: > >> >> >> On Wednesday, January 13, 2016 at 3:38:56 PM UTC-8, Tom Campbell wrote: >>> >>> Creating a custom form that relates first name and last name fields to >>> the db.auth_user's user_id field. In the form below the user ID shows as an >>> integer in the dropdown but I'd like it to show as the user's name. How do >>> I do that? >>> >>> form = SQLFORM.factory( >>> >>> Field('first_name', requires=IS_NOT_EMPTY()), >>> Field('last_name', requires=IS_NOT_EMPTY()), >>> Field('user_id', 'reference auth_user', requires=IS_IN_DB(db, >>> db.auth_user.id)), >>> fields=['first_name', 'last_name', 'user_id'], >>> ) >>> >>> I also tried this, but it sill displayed as an integer: >> Field('user_id', 'reference auth_user', >> widget=SQLFORM.widgets.options.widget, requires=IS_IN_DB(db, >> db.auth_user.id)), >> >> >> -- >> 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+un...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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.