How are your database modeling..
You are retrieving r.product.name but don't are in this row returned.. :/ .

Em sexta-feira, 7 de outubro de 2016 10:16:17 UTC-3, 黄祥 escreveu:
>
> *the code*
> @service.json
> def my_data():
>     query = (db.account.investor == 1)
>     rows = db(query).select(db.account.product.name, 
> db.account.subscription_amount, orderby = ~db.account.id).as_list()
>     return response.json(rows)
>
> *reproduce*
> [{"account": {"subscription_amount": 3.0}, "_extra": {"product": 3}}, 
> {"account": {"subscription_amount": 2.0}, "_extra": {"product": 2}}, 
> {"account": {"subscription_amount": 1.0}, "_extra": {"product": 1}}]
>
> format is not expected
>
> *format needed :*
> [['Dana Ekuitas', 1.0 ], ['Dana Likuid', 2.0 ], ['Dana Lancar', 3.0 ]]
>
> learned from anthony's solution in stackoverflow, he use return 
> json.dumps([[r.product.name, r.subscription_amount] for r in rows] )
> but it return string only, when tested the chart result is not expected (a 
> lot of data looping (redundant))
> how can i reproduce the format needed above?
>
> thanks and best regards,
> stifan
>

-- 
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.

Reply via email to