Open satyajeetnim opened 6 years ago
If you'd like help for something like this, please at least use code formatting and proper code indentation to make it easier for others to read.
@jeffoneill: Sorry about that, I have updated the original description to add code formatting and indentation to it. Thank !!!
@satyajeetnim Any news on this? It seems I am facing the same issue here.
Same problem here! Any news?
Use signals as described here: https://flask-security.readthedocs.io/en/latest/api.html?highlight=signals
where you initialize your app register a handler:
user_registered.connect(myuser.user_registered_sighandler, self)
That handler might look something like:
def user_registered_sighandler(sender, **extra):
# Add additional fields to new user - basic role
user = extra.get('user')
sender.db.add_role_to_user(user, 'basic')
sender.db.db.session.commit()
As for a create date - you can do that in your model __init__:
def __init__(self, **kwargs):
"""
:param kwargs: other init keys
"""
self.create_datetime = datetime.datetime.utcnow()
self.update_datetime = datetime.datetime.utcnow()
# overwrite with passed kwargs
super().__init__(**kwargs)
I have followed the steps listed here: https://pythonhosted.org/Flask-Security/customizing.html#forms Also I have looked at a lot of similar issues and tried the solutions mentioned there, but all in vain. Basically, I simply want to add a Name field in the registration form, but it isn't working. These are my changes:
forms.py ======
models.py
init.py
In addition to this I wanted to achieve 2 things:
Can someone tell me what it is that I am doing wrong and how should I add user role and creating date/time during registration.