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

challenge task 4 of 4

meet peewee; am getting a bummer which says challenge not in ascending order insted it is 1,5,2,. i don' t know where i am missing it. please help. thanks

queries.py
from models import Challenge

all_challenges = Challenge.select()

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

sorted_challenges = all_challenges.select().order_by()

3 Answers

Bhupend Patil
Bhupend Patil
25,918 Points

You made .select() in 2nd step so you don't have to write it again.

Should look like this: sorted_challenges = all_challenges.order_by() .

But then you have to specify records ordered by the steps attribute on the model i.e from imported Challenge class

So finally ordered by should look like this: order_by(Challenge.steps)

TASK 1 - 4

from models import Challenge

all_challenges = Challenge.select()

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

sorted_challenges = all_challenges.order_by(Challenge.steps)

Henry Howes
Henry Howes
4,767 Points

This question asks that the challenges be ordered with the steps attribute of Challenge, so this must be passed as a parameter to order_by().