I have the following tables defined and would like to display rows of cats,
followed by rows of dogs
db.define_table(‘cat’,
Field('name', 'string', length=45),
Field(‘age’, ‘integer’),
Field(‘apt_time’,’datetime’)
)
db.define_table(‘dog’,
Field('name', 'string', length=45),
Field(‘age’, ‘integer’),
Field(‘apt_time’,’datetime’)
)
#Controller
query = ((db.cat.age == 3) | (db.dog.age == 3))
union_rows = db(query).select()
print union_rows
The returned value is a single row object, containing an entry for each
table.
<Row {‘cat’: {'name': ‘FLUFFY’, 'age': 3L, 'apt_time':
datetime.datetime(2017, 4, 22, 16, 22, 10), }, ‘dog’: {'name': ‘SPOT’,
'age': 3L, 'apt_time': datetime.datetime(2017, 4, 22, 16, 22, 10), }}>
The output from SQLFORM.grid is below
*FLUFFY 3 2017-04-22 16:22:10 SPOT 3 2017-04-22
16:22:10*
What I need are two row objects, displayed in the SQLFORM as two rows.
*FLUFFY 3 2017-04-22 16:22:10*
*SPOT 3 2017-04-22 16:22:10*
I attempted to append row objects but that raises incompatible types, which
I believe is because of the different table names.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.