[web2py] Re: db two selects

2012-05-23 Thread BlueShadow
thank you so much for your help you really made my day > rows=db().select(db.Article.ALL, orderby=~db.Article.Submitted, limitby=(0 >> ,5)).sort(lambda row: >> row.Views, reverse=True) >> >

[web2py] Re: db two selects

2012-05-23 Thread Anthony
Documentation here: http://web2py.com/books/default/chapter/29/6#find,-exclude,-sort (though it appears the "reverse" argument isn't documented). Anthony On Wednesday, May 23, 2012 9:13:24 AM UTC-4, Anthony wrote: > > Sorry, I misunderstood what you were trying to do. I thought you wanted to >

[web2py] Re: db two selects

2012-05-23 Thread Anthony
Sorry, I misunderstood what you were trying to do. I thought you wanted to sort by date submitted and then by views, but you simply want to select the 5 most recently submitted and then sort those 5 by views only. To do that, first select the 5 most recent, and then use the Rows.sort() method:

[web2py] Re: db two selects

2012-05-15 Thread Larry Wapnitsky
If you resort to using Python code, let me know. I just did this for one of the lists in my database that has hit counts, dates, etc. On Sunday, May 13, 2012 3:27:56 PM UTC-4, pbreit wrote: > > I'm not sure that query will do what you want. I think you need to sort by > views separately.

[web2py] Re: db two selects

2012-05-13 Thread Anthony
Hmm, I tried a similar query and it properly respects both ~'s. Can you pack and attach a minimal app (using SQLite) that exhibits the problem? Anthony On Sunday, May 13, 2012 9:14:27 AM UTC-4, BlueShadow wrote: > > > def index(): > rows=db().select(db.article.ALL, orderby=~db.article.subm

[web2py] Re: db two selects

2012-05-13 Thread BlueShadow
def index(): rows=db().select(db.article.ALL, orderby=~db.article.submitted|~db. article.views, limitby=(0,5)) return dict(Articles=rows) Thats my code from the default.py removing and adding the second ~ doesn't change anything. in my index.htm I simply print the Titles and vi

[web2py] Re: db two selects

2012-05-13 Thread Anthony
orderedby=~db.article.date|~db.article.views should work. Did you try exactly that code? Anthony On Sunday, May 13, 2012 4:43:24 AM UTC-4, BlueShadow wrote: > > Hi I got A table for articles on my page wich contains a variable for the > date it was submitted and the number of views (content tit