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.

Devin Scheu
66,191 PointsPeeWee Python Help
Question: Create a function named create_challenge() that takes name, language, and steps arguments. Steps should be optional, so give it a default value of 1. Create a Challenge from the arguments. create_challenge should not return anything.
Code:
from peewee import *
from models import Challenge
def create_challenge(name, language, steps):
name = CharField(max_length=100)
language = CharField(max_length=100)
steps = IntegerField(default=1)
1 Answer

Dan Johnson
40,532 PointsYou don't need to define the model here, just create it using the Challenge model that is being imported. Since Challenge extends Model, you can call the create method on it.
Devin Scheu
66,191 PointsDevin Scheu
66,191 PointsSo what would this look like in code?
Dan Johnson
40,532 PointsDan Johnson
40,532 PointsFrom the peewee docs: http://peewee.readthedocs.org/en/latest/peewee/api.html#Model.create
Note that you won't need to capture the return for this challenge.
Devin Scheu
66,191 PointsDevin Scheu
66,191 PointsThanks Dan!