Добрый день.
Покажите пример регистрации пользователей в Flask по логин\паролю?
На ум пришла только такая тупость:
Модель:
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key = True)
email = Column(String(120), unique = True)
password = Column(String(64))
role = Column(Integer, default = ROLE_USER)
posts = relationship('Post', backref = 'author', lazy = 'dynamic')
def __init__(self, email=None, password=None):
self.email = email
self.password = password
Вьюха:
@app.route('/register', methods = ['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
u = User(form.login.data, hashlib.md5((form.password.data).encode('UTF-8')).hexdigest())
db_session.add(u)
db_session.commit()
return redirect('/index')
return render_template('register.html',
title = 'Registration',
form = form)