VIEW NAME NOT ID

81 views
Skip to first unread message

Ayron Rangel

unread,
Apr 30, 2018, 1:53:20 PM4/30/18
to web2py-users
 I have this:

db.py:
db.define_table('product_input',
    Field('product', db.product, notnull=True),
    Field('total_price','decimal(7,2)', readable=False,writable=False),
    Field('amount', 'integer', readable=False,writable=False),
    Field('supplier', db.supplier, notnull=True),
    Field('location', db.location, notnull=True),
    Field('input_type', 'string'),
    auth.signature,
    format = lambda r: '%s %s %s %s  [%s]' % (r.product.model.model, r.product.manufacturer.manufacturer, r.product.part_number, 
       r.product.serial_number, r.product.expiration_date)
    
    )

default.py: 
def stock():
    count = db.product_input.id.count()
    results = db(db.product_input).select(db.product_input.product, count, groupby=db.product)
    return locals()

view: 
{{for row in results:}}
<tr>
<td>{{=row[db.product_input.product]}}</td>
<td>{{=row[count]}}</td>
</tr>
{{pass}}


APPEARS JUST THIS:

Product in Stock [Model]Amount
62
72

HOW CAN APPEARS THE NAME NOT THE ID ON DE LINE?




Dave S

unread,
Apr 30, 2018, 2:57:55 PM4/30/18
to web2py-users

You need to tell web2py to display a reference field by the appropriate value; the index value is the default.

See 

Ayron Rangel

unread,
Apr 30, 2018, 3:21:12 PM4/30/18
to web2py-users
Sorry, man!

How can I put on my way?? based on my code!! 
 


 

pbreit

unread,
Apr 30, 2018, 11:51:22 PM4/30/18
to web2py-users

Peter

unread,
May 21, 2018, 3:42:01 PM5/21/18
to web2py-users
instead of this code:

<td>{{=row[db.product_input.product]}}</td>

try this (not tested) 
<td>{{=row.product.SOME_FIELD_NAME_FROM_PRODUCT_TABLE}}</td>
Reply all
Reply to author
Forward
0 new messages