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 trialDaniel Kolb
10,172 PointsWhat am I doing wrong Here?
I appear to not understand what to do with this API question
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 Ingredients(Model):
name = CharField()
description = CharField()
quantity = FloatField()
measurement_type = CharField()
recipe = ForeignKeyField()
class Meta:
database = DATABASE
from flask.ext.restful import Resource
import models
1 Answer
Rachel Johnson
Treehouse TeacherHey Daniel Kolb ! Great work so far, you're actually SUPER close!
First, the challenge is asking for an Ingredient
class, rather than an Ingredients
class.
Next, be sure to check the usage of a ForeignKeyField
, something is missing from the syntax that is causing an error. You can check this by revisiting the last two videos or by checking the Docs for Peewee!
Finally, quantity
is a DecimalField rather than a FloatField!
You got this! :D