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.
build social network with flask bcrypt excercise
I am facing this error when trying to submit this solution.
I have tried 2 ways to solve this. @classmethod and instantiating the User class.
Has anyone else faced the same issue? What am I missing in my solution?
import datetime from peewee import * from flask_login import UserMixin from flask.ext.bcrypt import generate_password_hash from flask.ext.bcrypt import check_password_hash class User(UserMixin, Model): username email password created is_admin class Meta: database = DATABASE order_by('-created',) def set_password(user, password): user=User() user.username = user user.password = generate_password_hash(password) return user
I get the following error
ERROR: test_results (main.TestFunctionDefinitionExecution)
Traceback (most recent call last): File "", line 55, in test_results File "/workdir/utils/challenge.py", line 25, in execute_source exec(src) File "", line 9, in File "", line 10, in User NameError: name 'username' is not defined
Ran 1 test in 0.015s
Thanks for the response, Jennifer. But this did not resolve the issue. I created the function within the class with proper indentation, however, I started getting a new error.