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 Flask REST API Resourceful Blueprints Ingredient Resource

Flask REST API Challenge 1.2

Pretty sure my code should work, but it keeps telling me to try again

models.py
import datetime

from peewee import *

DATABASE = SqliteDatabase('recipes.db')


class Recipe(Model):
    name = CharField()
    created_at = DateTimeField(default=datetime.datetime.now)

    class Meta:
        database = DATABASE

# TODO: Ingredient model
# name - string (e.g. "carrots")
# description - string (e.g. "chopped")
# quantity - decimal (e.g. ".25")
# measurement_type - string (e.g. "cups")
# recipe - foreign key

class Ingredient(Model):
    name = CharField()
    description = CharField()
    quantity = DecimalField()
    measurement_type = CharField()
    recipe = ForeignKeyField(Recipe, related_name="ingredients")

    class Meta:
        database = DATABASE
resources/ingredients.py
from flask.ext.restful import Resource

import models

class IngredientList(Resource):
    def get(self):
        return "string"

class Ingredient(Resource):
    def get(self, id):
        return "string"

I am having the same problem and could use a hand as well.

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Brian Li! I received your request for assistance and your code passes for me... both steps. It's possible that there is something being cached server side, I suppose. My best advice to you is to copy all this code somewhere, or alternatively, revisit this thread later. Start by restarting the challenge completely then trying. If that doesn't work, you might try either clearing your browser cache or logging in from another browser so as to have a fresh session. I'm inclined to believe it has (somehow) a cached version of your answer which doesn't pass. But this code passes with flying colors for me when copy/pasted in.

Hope you get this figured out! :sparkles:

I might be a bit late to this party but just in case it might help someone else, I found that a mix of spaces and tabs was causing the issue for me. I converted to spaces only and it passed.