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

Gabriel Walsh
Gabriel Walsh
21,531 Points

PeeWee Hurtmen

I can not figure out why this won't work. It seems to follow the API documentation

crud.py
from models import Challenge


def create_challenge(name, language, steps=1):
    Challenge.create(name=name,
                     language=language,
                     steps=steps)

def search_challenges(a_name, a_lang):
    q = Challenge.select().where(Challenge.name == a_name).where(Challenge.name == a_lang)
    q_two =  Challenge.select().where(Challenge.name == a_name, Challenge.name == a_lang)
    return q_two

2 Answers

Nicole Homeier
Nicole Homeier
2,664 Points

I'm having the same issue, did you figure this out?

josephr
josephr
18,877 Points

I imagine you have already figured this out, but I was just having difficulty with it and had a hard time finding a solution.

My mistake was a silly one name is contains and the equality only holds for the language.

Challenge.name.contains(name) ...