Ok, I have the reason why i got this KeyError. The problem was not on table 'fab_lote', the problem was in table 'db.fabricacion'.
The argument 'format' in definition of table db.fabricacion was wrong and the field 'nombre' does not exis in this table: db.define_table('fabricacion', Field('escandallo', db.escandallo, writable=False), Field('cantidad', 'double'), Field('fecha_alta', 'date', default=datetime.date.today(), writable=False), Field('fecha_mod', 'date', writable=False), Field('cerrado', writable=False, default='no'), Field('lote_fabricado', db.lote, writable=False), Field('observaciones', widget=SQLFORM.widgets.text.widget), format='%(nombre)s')) So that's it. Juan A. On 24 jun, 17:44, Juan Antonio <juanr...@gmail.com> wrote: > Hello, > > Together with others tables I have this in my db.py file: > ....... > db.define_table('fab_lote', > Field('fabricacion', db.fabricacion), > Field('lote', db.lote), > Field('cantidad_orden', 'double'), > Field('cantidad_gastado', 'double'), > Field('coste_unitario', 'double')) > ........ > > when I click on 'db.fab_lote ' in the database admin api I get: > Traceback (most recent call last): > File "/home/jaromero/juan/programacion/web2py/gluon/restricted.py", > line 192, in restricted > exec ccode in environment > File "/home/jaromero/juan/programacion/web2py/applications/ > librefactory/views/appadmin.html", line 161, in <module> > <strong>{{="%02d" % ram['oldest'][1]}}</strong> minutes > File "/home/jaromero/juan/programacion/web2py/gluon/sqlhtml.py", > line 1366, in __init__ > r = A(field.represent(r), _href=str(href)) > File "/home/jaromero/juan/programacion/web2py/gluon/dal.py", line > 3631, in repr_ref > def repr_ref(id, r=referenced, f=ff): return f(r, id) > File "/home/jaromero/juan/programacion/web2py/gluon/dal.py", line > 3604, in ff > return r._format % row > File "/home/jaromero/juan/programacion/web2py/gluon/dal.py", line > 3697, in __getitem__ > return dict.__getitem__(self, key) > KeyError: 'nombre' > > But field 'nombre' is not anymore in this table. > > I get the same in some controllers. > > From the shell I can get the data from this table with select() > without any problem. why do I get this KeyError?