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!
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
How do I use the 'where' clause?
How do I design my query if 'Challenge' has no attribute 'where' (i.e. Challenge.where() is giving a syntax error)
from models import Challenge def create_challenge(name, language, steps=1): Challenge.create(name=name, language=language, steps=steps) def search_challenges(name, language): search = Challenge.select() return search where(name==name, language==language)
Megan AmendolaTreehouse Teacher
At about 6:54 in the video before is where he talks about
.where() can either attached on to the end of
Challenge.select().where(logic here) or since you hade it a variable, you can use the variable
Here are some examples from the documentation as well: http://docs.peewee-orm.com/en/latest/peewee/querying.html#filtering-records