db.define_table('store_registration',
Field('first_name', requires=IS_NOT_EMPTY()),
Field('last_name', requires=IS_NOT_EMPTY()),
Field('contact_number', label=SPAN('Cell Number'), requires=IS_NOT_EMPTY()),
Field('id_number', requires=IS_NOT_EMPTY()),
Field('program', requires=IS_NOT_EMPTY()),
Field('level_is', label=SPAN('Level'), requires=IS_NOT_EMPTY()),
Field('module_is', label=SPAN('Module'), requires=IS_NOT_EMPTY()),
Field('branch', label=SPAN('Branch'), requires=IS_NOT_EMPTY()),
Field('residential_place', label=SPAN('Residence'), requires=IS_NOT_EMPTY()),
Field('region', 'reference auth_group', default=get_group(), writable=False), #*Here*
Field('recorded_by', 'reference auth_user', default=auth.user_id, writable=False),
format="%(first_name)s %(last_name)s"
)
db.define_table('temperatures',
Field('employee', 'reference store_registration', writable=False),
Field('branch', 'reference store_registration', writable=False),
Field('temperature', requires=IS_NOT_EMPTY()),
Field('ID_No', 'reference store_registration', writable=False),
Field('Cell_No', 'reference store_registration', writable=False),
Field('residential', 'reference store_registration', writable=False))
def client_details():
details=db.store_registration(request.args(0, cast=int)) db.temperatures.employee.default=details.id
db.temperatures.ID_No.default=details.id_number
db.temperatures.Cell_No.default=details.contact_number
db.temperatures.branch.default=details.branch
db.temperatures.residential.default=details.residential_place
form=SQLFORM(db.temperatures)
if form.process().accepted:
response.flash=T('Temp Recorded')
return locals()<type 'exceptions.ValueError'> invalid literal for long() with base 10:I read somewhere that this occurs because
reference fields are intended to store the integer record ID's of the referenced records, not copies of string
fields from referenced records.
Is there a way I can achieve my above task without causing this error?!Regards;
Mostwanted
contact_number, id_number, branch, residential_place) to be unpacked & stored with the new details (temperature) in the temperature table without me having to re-enter them again, isnt there a way for this?Field('store_registration_id', 'reference store_registration', writable=False),