miguelgrinberg / flasky

Companion code to my O'Reilly book "Flask Web Development", second edition.
MIT License
8.52k stars 4.2k forks source link

error when trying to create an user with a pw #535

Closed TheBubblePopped closed 2 years ago

TheBubblePopped commented 2 years ago

the class User has two functions as properties

 @property
    def password(self):
        raise AttributeError('password is not a readable attribute')

    @password.setter
    def password(self, password):
        self.password_hash = generate_password_hash(password)

When i try to use User(password='something') as it's written in the tests i get an error. init() got an unexpected keyword argument 'password'

Why?

miguelgrinberg commented 2 years ago

@TheBubblePopped Have you made any changes to the __init__() method in this model that produces this error?

TheBubblePopped commented 2 years ago

Actually yes, i found the bug. Ty