Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Using Databases in Python Meet Peewee First Queries

Jack Cummins
Jack Cummins
17,417 Points

I don't know what to do next

Would you please give me the code and explain why the code makes sense. The task is: Finally, make a variable named sorted_challenges that is all of the Challenge records, ordered by the steps attribute on the model. The order should be ascending, which is the default direction.

Thanks SO Much! Jack

queries.py
from models import Challenge 

all_challenges = Challenge.select()

Challenge.create(language='Ruby', name='Booleans')

sorted_challenges = Challenge.select().order_by()

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Jack Cummins! I received your request for assistance and you are super close on this one. You've imported the model, selected all the challenges, and even created a new one! However, the problem is in your last line. You are asked to sort the challenges and order them by the "steps" attribute on the model. You've included the order_by, but you haven't told it what it's supposed to order by. So your last line should be:

sorted_challenges = Challenge.select().order_by(Challenge.steps)

Hope this helps! :sparkles: