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 A Social Network with Flask Broadcasting Post Model

No value for argument 'model' in constructor call

class Post(Model):
    timestamp = DateTimeField(default=datetime.datetime.now)
    user = ForeignKeyField(
        rel_model=User,
        related_name='posts'
    )
    content = TextField()

    class Meta:
        database = DATABASE
        order_by = ('-timestamp',)

This code is throwing the above error. Googling it, every post is saying that i'm missing a positional argument in my init function but the class as Kenneth writes it doesnt have one, so I have no idea what's going wrong.

2 Answers

Don't know if it's just the video is out of date but the peewee documentation gives the user assignment to be

user = ForeignKeyField(User, backref='posts')

and that fixed it. Just in case anyone else gets this issue.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,457 Points

I've marked you question as "feedback" so the developers will see it. Thanks!

user = ForeignKeyField(
        model={User},  # added
        rel_model=User,  # point to the User model
        related_name='posts'  # who call and name their post
    )

I tried to see the document and added to fix it.