Ok, I got it. Yes,there is only one record for one pro_id.
The 2nd one works, but now a new problem arises. I am getting the record 
that I want to edit, but on submitting it, a new blank form is 
generated(which is undesired). When I submit this form with dummy values, 
this form is getting inserted into the db but the changes/update I made on 
the record are not replicated to the db.


On Wednesday, July 2, 2014 7:31:29 PM UTC+5:30, Massimo Di Pierro wrote:
>
> The problem is that here:
>
> testform = 
> SQLFORM(db.products,db(db.products.product_id==request.post_vars.pid).select(),
>  fields=['product_id','price','pro_type','tags','category','description']))
>
> the result of a select is a Rows and not a Row. Do you know there is a 
> single matching record? In this case:
>
> testform = 
> SQLFORM(db.products,db(db.products.product_id==request.post_vars.pid).select().first(),
>  fields=['product_id','price','pro_type','tags','category','description']))
>
> or
>
> testform = SQLFORM(db.products, 
> db.products(product_id=request.post_vars.pid), 
> fields=['product_id','price','pro_type','tags','category','description']))
>
> Mind that the pid of the product you want to edit should not be a POST 
> parameter but a GET parameter. According to REST it is used to identify the 
> resource you want to edit therefore it belongs to the URL not to the posted 
> data.
>
> Massimo
>
>
>
> On Wednesday, 2 July 2014 06:05:31 UTC-5, Shubham Jain wrote:
>>
>> I want to create an update page just like profile page in default 
>> application. Actually I am passing the primary key of a table by a button 
>> click to the product_update page. In the controller of the update page I 
>> tried these 2 codes.
>>
>> def product_edit():
>>     db.products.product_id.writable=FALSE           # to make product_id 
>> non editable
>>     db.products.product_id.readable=TRUE
>>     testform = 
>> SQLFORM(db.products,db(db.products.product_id==request.post_vars.pid).select(),
>>  fields=['product_id','price','pro_type','tags','category','description']))
>>     return dict(form=testform)
>>
>>           
>>  
>> --------------OR---------------------------------------------------------------------------------
>>
>>     dform = 
>> SQLFORM(db.products,record=db(db.products.product_id==request.post_vars.pid).select(),
>>  
>> fields=['product_id','price','pro_type','tags','category','description'])
>>     return dict(form=dform)
>>
>>       pid - name of the input which has the product_id.
>> But these don't work.
>>
>> Error Generated: TypeError: list indices must be integers, not str
>>
>>

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

Reply via email to