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 trialZachary Snyder
6,659 PointsNot sure what im missing here.
Ive been staring at this for quite a bit of time now trying to figure out what im missing. Maybe I used one of the wrong field types?
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
class Ingredient(Model):
name = CharField()
description = TextField()
quantity = DecimalField()
measurement_type = CharField()
recipe = ForeignKeyField()
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
from flask.ext.restful import Resource
import models
Zachary Snyder
6,659 PointsAll the Challenge tells me is Bummer try again. Shane Robinson
Shane Robinson
7,324 PointsAh, it's always disheartening when the error messages are of no use. :p I've been giving it a good hard look and I can't find anything wrong off the bat. I'll get back to you if I find anything, if not - hopefully somebody more experienced will come along and give their assistance. :)
1 Answer
Shane Robinson
7,324 PointsAlright, so it's two things. First, the description should be a CharField().
Second, there should be parameters inside the ForeignKeyField (read this documentation for more info/why). Shown here:
recipe = ForeignKeyField(Recipe ,related_name = 'ingredient_set')
Shane Robinson
7,324 PointsShane Robinson
7,324 PointsAre you getting some sort of error message? If so, could you post it here? That would be useful in figuring out your issue. :)