Welcome to the Treehouse Community
Looking to learn something new?
Clayton PerszykTreehouse Moderator 48,107 Points
problem with search_challenges (receiving AttributeError)
I keep receiving the error: AttributeError: 'NoneType' object has no attribute 'count'... I've researched the error message to no avail. I've also looked at the documentation for the select() and where() methods, and feel like i'm calling them correctly. Thanks in advance for any help.
from models import Challenge def create_challenge(name, language, steps=1): Challenge.create(name=name, language=language, steps=steps) def search_challenges(name, language): challenges = Challenge.select() challenges.where(Challenge.name.contains(name) & Challenge.language == language)
Yes, the word 'return' is needed:
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.contains(name), Challenge.language==language )
Of course, this didn't help me, because by the time I found this thread I had already moved on to the next challenge:
Challenge Task 1 of 1
Create a function named delete_challenge that takes a Challenge as an argument. Delete the specified Challenge. Your function shouldn't return anything.
Watch the video over and over again:
..at about time index 2:43 I found (and re-typed since there is no way to OCR text from the videos):
def delete_entry(entry): entry.delete_instance()
..which I eventually 'translated' to:
def delete_challenge(Challenge): Challenge.delete_instance()
Note: I wish this challenge wasn't so new...couldn't find many threads on it..