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 Gettin' CRUD-y With It CRUD: Search Function

CRUD: 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.

crud.py
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
Dan Johnson
40,533 Points

For 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.

Thanks I guess I misread it.

Nadine Abella
Nadine Abella
1,032 Points

Dan Johnson so how exactly would that look like because I'm stuck here too

Ryan McGuire
Ryan McGuire
3,758 Points

return Challenge.select().where(Challenge.name.contains(name), Challenge.language==language)

Lauren O'Brien
Lauren O'Brien
7,420 Points

Check out the .contains() method Kenneth covered in the previous lesson segment.

Just 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.