Flask-Security init: unexpected keyword argument 'password'
If you look at Flask-Security's datastore.py
you can see what .create_user()
does:
def create_user(self, **kwargs): """Creates and returns a new user from the given parameters.""" kwargs = self._prepare_create_user_args(**kwargs) user = self.user_model(**kwargs) return self.put(user)
It's simply trying to instantiate the given User
model. To fix, adjust the __init__
method in your User
model to handle a password
element like so:
def __init__(self, **kwargs): self.password = kwargs['password'] self.email = kwargs['email'] if kwargs.get('first_name', False): self.first_name = kwargs['first_name'] self.last_name = kwargs['last_name'] #roster stuff...