0
I can’t fix one error that appears when I try to expose a form to two tables of the 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, Nvironment) 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.Student) 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 documentation of Framework
. If anyone can help me I’d be very grateful.