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

Justin Smith
Justin Smith
3,495 Points

IntegrityError: challenge.name may not be NULL

Why am I getting this error? I tried to set the name argument to a value but that didn't work either.

crud.py
from models import Challenge

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

create_challenge('tiff', 'python')

1 Answer

It looks like there is a validation on either the model or the database when you create a new Challenge instance. Right now you're trying to create a challenge without parameters which means the challenge would not have a name, language or steps initialized with it causing that validation error.