I can not resolve an error that appears when I try to expose a form to two tables of SQLite
.
The error is as follows:
Traceback (most recent call last): File "/home/joao/Desktop/web2py/gluon/restricted.py", line 219, in restricted exec (ccode, environment) File "/home/joao/Desktop/web2py/applications/vr/controllers/default.py", line 101, in File "/home/joao/Desktop/web2py/gluon/globals.py", line 409, in self._caller = lambda f: f () File "/home/joao/Desktop/web2py/applications/vr/controllers/default.py", line 55, in register_student form = SQLFORM.factory (db.Person, db.Alumn) File "/home/joao/Desktop/web2py/gluon/sqlhtml.py", line 1922, in factory return SQLFORM (DAL (None) .define_table (table_name, * [field.clone () for field in fields]), AttributeError: 'Table' object has no attribute 'clone'
My controller and my model are as follows:
Model:
db.define_table('Pessoa',
Field('nome',required=True,notnull=True),
Field('cpf',required=False,notnull=True,length=11),
Field('data_de_nascimento',type='date',required=False,notnull=True),
Field('cep',notnull=True,length=8),
Field('uf',notnull=True,length=2),
Field('pai',notnull=True),
Field('mae',notnull=True),
Field('identidade',notnull=True,length=13),
Field('expedicao_identidade',type='date',required=False,notnull=True),
Field('tipo_sanguineo',notnull=True,length=3),
Field('orgao_emissor',notnull=True,length=20),
Field('doador',type='boolean', notnull=True),
Field('origem',notnull=True,length=40),
Field('observacao',notnull=True),
auth.signature,
)
db.define_table('Aluno',
Field('pessoa_id', 'reference Pessoa', writable=False, readable=False),
# Field('nota_fiscal_id', 'reference Nota_fiscal', writable=False, readable=False),
Field('matricula', notnull=True, length=7),
Field('renach', notnull=True, length=40),
Field('categoria', notnull=True, length=5),
Field('servico', notnull=True),
Field('status', notnull=True),
auth.signature,
)
Controller:
def register_student():
form = SQLFORM.factory(db.Pessoa,db.Aluno)
if form.process().accepted:
id = db.Pessoa.insert(**db.Pessoa._filter_fields(form.vars))
form.vars.client=id
id = db.Aluno.insert(**db.Aluno._filter_fields(form.vars))
response.flash='Aluno cadastrado com sucesso!'
return dict(form=form)
I did all this based on the official Framework
documentation. If anyone knew how to help me, I would be very grateful.