[web2py] Re: VIEW NAME NOT ID

2018-05-21 Thread Peter
instead of this code:

{{=row[db.product_input.product]}}

try this (not tested) 
{{=row.product.SOME_FIELD_NAME_FROM_PRODUCT_TABLE}}



On Monday, April 30, 2018 at 7:53:20 PM UTC+2, Ayron Rangel wrote:
>
>  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:}}
> 
> {{=row[db.product_input.product]}}
> {{=row[count]}}
> 
> {{pass}}
>
>
> APPEARS JUST THIS:
>
> Product in Stock [Model]Amount
> 6 2
> 7 2
>
> HOW CAN APPEARS THE NAME NOT THE ID ON DE LINE?
>
>
>
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: VIEW NAME NOT ID

2018-04-30 Thread pbreit
Are you trying to do something like this?

http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Grouping-and-counting

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: VIEW NAME NOT ID

2018-04-30 Thread Ayron Rangel

>
> Sorry, man!
>

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


 

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: VIEW NAME NOT ID

2018-04-30 Thread Dave S


On Monday, April 30, 2018 at 10:53:20 AM UTC-7, Ayron Rangel wrote:
>
>  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:}}
> 
> {{=row[db.product_input.product]}}
> {{=row[count]}}
> 
> {{pass}}
>
>
> APPEARS JUST THIS:
>
> Product in Stock [Model]Amount
> 6 2
> 7 2
>
> HOW CAN APPEARS THE NAME NOT THE ID ON DE LINE?
>
>
You need to tell web2py to display a reference field by the appropriate 
value; the index value is the default.

See  
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#format--Record-representation>

and the example in
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#One-to-many-relation>

/dps

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.