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
Clayton PerszykTreehouse Moderator 48,605 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..