Ahhh, that's exactly what it was... was missing the little apostrophes
(').
The final syntax ended up being with the square brackets:
{{=row['COUNT(game_session.createdBy)']}}
Thank you very much for your help.
On Oct 14, 8:06 pm, ron_m <[email protected]> wrote:
> Just add a
>
> print row
>
> before the =row(count) line and see what the structure of the row
> looks like from the console.
>
> It might be row['count'] depending on how your data is structured.
>
> On Oct 14, 5:20 pm, Alex <[email protected]> wrote:
>
>
>
> > Hmm, I gave it a try on the view and it doesn't seem to like it.
>
> > I'm doing this on the view:
>
> > {{for row in ranking:}}
> > <tr>
> > <td>{{=row.auth_user.first_name}} {{=row.auth_user.last_name}}</
> > td>
> > <td>{{=row(count)}}</td>
> > </tr>
> > {{pass}}
>
> > and it's throwing a "name count is not defined" error.
>
> > Am I still missing something?
>
> > On Oct 14, 9:53 am, Alex <[email protected]> wrote:
>
> > > Ahh thank you very much. I'll give it a try. If this is the case,
> > > then I believe the syntax example in the book/online is incorrect.
>
> > > Chapter 6 - DAL - Grouping and Counting section
>
> > > The book uses square brackets [] instead of parenthesis ().
>
> > > On Oct 14, 9:13 am, mdipierro <[email protected]> wrote:
>
> > > > ok. You just want
>
> > > > for row in rows: print row.auth_user.first_name, row(count)
>
> > > > On Oct 14, 6:17 am, Alex <[email protected]> wrote:
>
> > > > > Sure thing.
>
> > > > > I have something like:
>
> > > > > count = db.game_session.createdBy.count()
> > > > > rankings = db((db.game_session.gameWinner == "1") &
> > > > > (db.game_session.createdBy ==
> > > > > db.auth_user.id)).select(db.auth_user.first_name,
> > > > > db.auth_user.last_name, count, groupby=db.game_session.createdBy)
>
> > > > > return dict(rankings = rankings)
>
> > > > > On the view I just want to get to reference/display the count column
> > > > > in each row.
>
> > > > > Thanks!
>
> > > > > On Oct 14, 12:32 am, mdipierro <[email protected]> wrote:
>
> > > > > > show us the query.
>
> > > > > > On Oct 13, 10:47 pm, Alex <[email protected]> wrote:
>
> > > > > > > Hello,
>
> > > > > > > I have a query that does a select and COUNT on my model. I wish
> > > > > > > the
> > > > > > > present the COUNT value of each row on the view but am having
> > > > > > > trouble
> > > > > > > figuring out the syntax for doing this.
>
> > > > > > > I have a for loop, iterating through each row in the resultset and
> > > > > > > tried to follow the example in the book, by using {{=row[count]}}
> > > > > > > but
> > > > > > > to no avail.
>
> > > > > > > I took a look at the objects in the row, and noticed that an
> > > > > > > "_extra"
> > > > > > > object is returned in the resultset. Looking at the keys in the
> > > > > > > "_extra" dictionary, I do see the key based on my COUNT column:
>
> > > > > > > ie. COUNT(db.table_name.column)
>
> > > > > > > I tried to access the count value with {{=rows._extra.colName}},
> > > > > > > but
> > > > > > > still had no luck. Is there something obvious I am missing?
>
> > > > > > > Thanks!
>
> > > > > > > I have tried something like:
>
> > > > > > > {{for row in ranking:}}
> > > > > > > <tr>
> > > > > > > <td>{{=row.auth_user.first_name}}
> > > > > > > {{=row.auth_user.last_name}}</
> > > > > > > td>
> > > > > > > <td>{{=row[count]}}</td>
> > > > > > > </tr>
> > > > > > > {{pass}}- Hide quoted text -
>
> > > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -