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 Build a Social Network with Flask Making Strong Users What's a method like you doing in a class like this?

why is this not passing? please help =)

Challenge Task 1 of 2

Add a @classmethod to User named new. It should take two arguments, email and password. The body of the method can be pass for now. Remember, @classmethods take cls as the first argument. ... why is this not passing? please help =)

models.py
import datetime

from flask.ext.bcrypt import generate_password_hash
from flask.ext.login import UserMixin
from peewee import *

database = SqliteDatabase(':memory:')

class User(Model):
    email = CharField(unique=True)
    password = CharField(max_length=100)
    join_date = DateTimeField(default=datetime.datetime.now)
    bio = CharField(default='')

    class Meta:
        database = database   

    @classmethod
      def new(email, password);
    pass

Challenge Task 1 of 2

Add a @classmethod to User named new. It should take two arguments, email and password. The body of the method can be pass for now. Remember, @classmethods take cls as the first argument.

3 Answers

You forgot the cls as the first argument and you used a semi colon instead. So it should look like

@classmethod
def new(cls, email, password):
    pass
Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

You don't need to indent the method past the decorator. You also didn't give a body to your method and method blocks start with a colon, :, not a semicolon, ;. And, finally, you didn't provide an argument for the class.

Kenneth can you post the full code

Andrew Winkler
Andrew Winkler
37,739 Points

Trying the code above only got me indentation errors. After reviewing Kenneth's comments, I got this to work though:

    @classmethod
    def new(cls, email, password):
      pass    

Indentation errors begone!