I'm sure I'm missing something obvious but I am trying to alter the representation of a referenced field in a SQLFORM and failing hopelessly (Web2Py 2.20.4 on Python 3.7.7). The two tables involved are:
db.define_table('markers', Field('first_name','string'), Field('last_name','string'), Field('email', 'string', requires=IS_EMAIL()), format='%(first_name)s %(last_name)s') db.define_table('assignments', Field('student_first_name','string', notnull=True), Field('student_last_name','string', notnull=True), Field('marker','reference markers')) Most of the time, I want marker names as "John Smith", so have set that as the format in the model. However in a SQLFORM to create a new assignment, I want the dropdown to be "Smith, Bob (b...@smith.org)", to make it easier to find people. So: def new_assignment(): db.markers._format = '%(last_name)s, %(first_name)s (%(email)s)' form = SQLFORM(db.assignments) if form.process().accepted: response.flash = 'Assignment created' redirect(URL('assignments')) return dict(form=form) But that does not change what appears in the SQLFORM dropdown menu for marker. If I swap the format string in the model, yup, exactly as expected, but it doesn't seem to be respecting the local redefinition. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/a38b94bf-f5d6-47be-83d7-412fb49c51a6o%40googlegroups.com.