Use belongs (http://web2py.com/books/default/chapter/29/06#belongs)
db(db.Articles.User.belongs([make,user_ids,into,a,list])).select()
On Saturday, September 8, 2012 9:48:43 PM UTC+8, BlueShadow wrote:
>
> I got a table for articles which contains an ids of users which commented
> on that particular image.
> now I like to read all the user ids of an particular aricle and display a
> list off all articles those users commented on.
> here is my first attempt: but its pretty aweful:
> db.define_table('Article',
> Field('Title'),
> Field('content','blob'),
> Field('Users','list:reference auth_user'),
>
> Field('Submitted','datetime',default=datetime.datetime.now(),writable=False,readable=False)
> )
> model:
>
> def displaylist():
> id=request.vars.id
> row=db(db.Articles.id==id).select()
> row=row[0]
> Userids=row.Users
> related=[]
> for i in Userids:
> related.append(db().select(db.Articles.User,i))
> return dict(originalArticle=row,related=related)
>
> view:
> {{for i in related:}}
> {{#=some funky select}}
> {{pass}}
>
--