對不起,如果標題不清楚,想不到一個好的方式來制定它。 目前我檢查,如果它沒有父視圖則顯示它 我想這個改變控制器(顯然)數據庫有兩種不同的表格要求
我的表:
db.define_table('comments',
Field('parent_id', 'reference comments', readable=False, writable=False),
Field('body', 'text', label='Message', requires=IS_NOT_EMPTY()),
auth.signature)
db.define_table('comments_users',
Field('user_id', 'reference auth_user', requires=IS_NOT_EMPTY()),
Field('comments_id', 'reference comments', requires=IS_NOT_EMPTY()),
Field('permission', 'integer', requires=IS_NOT_EMPTY()))
的選擇我想那並不是」將不起作用:
rows = db(
(db.comments_users.user_id==auth.user.id) &
(db.comments_users.comments_id.parent_id==0) # something like this is possible in view with a single row
).select(limitby=(0, 10))
我現在做中,我想改變控制器
{{for row in rows:}}
{{if row.comments_id.parent_id==0:}}
<td>{{=row.comments_id}}</td>
{{pass}}
{{pass}}
視圖
非常感謝你 我在嘗試加入之前遇到的問題是我忘記了(db.comments.id == db.comments_users.comments_id)),這只是我身邊的愚蠢。 – PrivateerGerrit 2014-10-20 17:33:33