Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Using Databases in Python Meet Peewee First Queries

Why is it saying that my task one no longer works?

Task 1 and 2 were fine until I added the line:

Challenge.create(name="Ruby", language="Boolean")

from peewee import *

db = SqliteDatabase("challenges.db")

class Challenge(Model):
    name = CharField(max_length=100, unique=True)
    language = CharField(max_length=100, unique=True)

    class Meta:  #describes class it belongs to
        database = db

all_challenges = Challenge.select()


2 Answers

Ryan S
Ryan S
27,276 Points

Hi Marley,

You have your "name" and "language" variables mixed up and have assigned them the opposite values than what the challenge specifies.

However, this isn't the main issue with your code and fixing the arguments still won't allow it to pass. It seems that on task 1, you defined a class from scratch instead of following the instructions of the challenge:

Import the Challenge class from models.py.

Note that this does not instruct you to define a "Challenge" class, specify your own attributes, and set up a database.

"Challenge" already exists and you are simply asked to import it:

from models import Challenge

The reason your code passed at first is that you have essentially tricked the code checker in task 1 into thinking you successfully imported its predefined Challenge model. But in doing so, you made some assumptions about the structure of the model, and when you get to task 3 you find out that those assumptions are incorrect. That is why it is always important to read the instructions carefully.

Hope this helps.

Chris Howell
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,610 Points

Hi Marley Alford

Read what the challenge asks for carefully.

Next, create a new Challenge. The language should be "Ruby", the name should be "Booleans".

name should be "Booleans"

language should be "Ruby"