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 Using Databases in Python Gettin' CRUD-y With It CRUD: Create Function

Kade Carlson
Kade Carlson
5,928 Points

Not quite sure what this is asking

I could just be overthinking this but I'm not exactly sure what this is asking me to do

from models import Challenge

def create_challenge(name, language, steps):
    name = CharField(max_length=255)
    language = CharField(max_length=255)
    Steps = IntegerField(default=1)


1 Answer

Ryan Kriegbaum
Ryan Kriegbaum
16,180 Points

I wasn't too clear on this one either, but I'll see if I can help out.

tl/dr What I ended up with was something like:

from models import Challenge

def create_challenge(new_name, new_language, new_steps=1):
    Challenge.create(name=new_name, language=new_language, steps=new_steps)

For your code, you can get rid of the data declaration because we imported Challenge (already declared, maybe a few lessons back?). If you play around a bit (or have it saved somewhere, or just remember) you'll see that Challenge has data fields ('columns') with the exact same names of the arguments we are supposed to be passing through - 'name' 'language' and 'steps'. Since we are being asked to fill in information ('values') with the information being passed through the create_challenge function's arguments, we can just finish that create() statement with those arguments. Should be something like Challenge.create(column = value, etc, etc).

Hope that helps