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 trialAlvin McNair
3,398 PointsCRUD: python databases, What am I missing in the search_challeges function
It looks right to me is there a missing include or am I just returning the wrong thing here.
from models import Challenge
def create_challenge(name, language, steps=1):
Challenge.create(name=name,
language=language,
steps=steps)
def search_challenges(name,language):
return Challenge.select().where(Challenge.name == name,Challenge.language == language)
4 Answers
Dan Johnson
40,533 PointsFor the name argument you'll want to be checking if any part of that is contained in the name stored in the database, not just for exact matches.
Nadine Abella
1,032 PointsDan Johnson so how exactly would that look like because I'm stuck here too
Ryan McGuire
3,758 Pointsreturn Challenge.select().where(Challenge.name.contains(name), Challenge.language==language)
Lauren O'Brien
7,420 PointsCheck out the .contains() method Kenneth covered in the previous lesson segment.
Beau Genereux
5,362 PointsJust a quick FYI, the challenges in this course are quite difficult to understand compared to all the other courses in the Flask Basics Track. It seems like all the other challenges repeat what you just learned with multiple steps quiz, then all of a sudden this course throws a paragraph of explanation along with details as to what you might need and shouldn't have to use for a concept you just learned — maybe it's me just being tired but I've been struggling with this course a lot more than with the others.
Alvin McNair
3,398 PointsAlvin McNair
3,398 PointsThanks I guess I misread it.