Issue 264.
On May 6, 5:59 pm, Massimo Di Pierro <[email protected]> wrote: > Please open an issue in google code > > ---------- Forwarded message ---------- > From: villas <[email protected]> > Date: May 6, 10:56 am > Subject: CRUD.search sorting order > To: web2py-users > > Hi Niknok > > I have looked at this in a little more detail now. The main problem > seems to be that web2py does not accept the orderby argument for > crud.search. > > ** I believe this is a bug ** > > I think it should be possible to fix this easily enough in tools.py > but it is best if someone with more experience confirms this issue. > > Best regards, D > > On May 6, 2:00 pm, niknok <[email protected]> wrote: > > > Thanks for the response Villas. > > > Do note that my use of > > fields=['id','last_name','first_name', ... > > is based on examples in the book . I tried your suggestions, sadly, > > I'm getting a KeyError error message. W2P complaining about the > > "db.auth_user" table names... Have you tried this out yourself and is > > it working in your system? > > > As for orderby, the use of built-in python functions (i.e. > > orderby=db.auth_user.last_name.lower() ...) are documented in the > > book. > > > So I suppose the issue is something else? > > > /r > > > On May 4, 11:45 pm, villas <[email protected]> wrote: > > > > I should have also said that I think the fields should be fields and > > > not strings: > > > i.e. > > > fields = [db.auth_user.id, db.auth_user.last_name, ....] > > > > On May 4, 2:47 pm, niknok <[email protected]> wrote: > > > > > I'm using v1.94.6 and retrieving ordered search results from crud.search > > > > always produces a list sorted by id > > > > > Tried various combinations: > > > > > orderby=db.auth_user.last_name > > > > orderby=db.auth_user.birth_date > > > > > > > > orderby=db.auth_user.last_name.lower()|db.auth_user.first_name.lower() > > > > > Attached is a screenshot with orderby set to last entry above. > > > > > The code I use is: > > > > > form,rows = crud.search(db.auth_user > > > > > > > > ,query=(db.auth_user.account_type==0)&(db.auth_user.id!=auth.user.id) > > > > ,fields=['id','last_name','first_name','middle_name','birth_date'] > > > > > > > > ,orderby=db.auth_user.last_name.lower()|db.auth_user.first_name.lower() > > > > ,queries=['equals','contains','starts with','ends with','greater > > > > than','less than']) > > > > > Did I miss anything or doing something wrong here? > > > > > /r > > > > Nik > > > > > crud.search-sorting.png > > > > 103KViewDownload > >

