Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Hanley Chan27,771 Points
Help with quiz question regarding sorting based on published attribute.
I am having trouble with this quiz question:
In the following query, I want to change the sorting of my records. How would I sort them based on their published attribute so I get the oldest first?
I tried "Entry.select().order_by(Entry.published.desc())", but it is not correct. What is the correct answer for this one?
Keith Whatling17,696 Points
Finally after 5 tries!
Ok so the thing we are all doing wrong it being too damn complex. Leave all reference to asc() and desc(), no need for plus and minus. Grr that was really frustrating.
The PeeWee docs are missing the bit that tell you that there is a default to order_by, or the treehouse test needs a little tweak.
Hope this helps.
Anna Hull6,600 Points
I am working on this quiz right now as well - according to the PeeWee Docs this should work:
Or one of these:
Kenneth Love, maybe you can help us out with this one!
This question was also answered here on Treehouse Forums.