У меня есть db.py:
from run import db
from werkzeug.security import generate_password_hash, check_password_hash
class User(db.Model):
__tablename__ = "User"
id = db.Column(db.Integer, primary_key=True)
nickname = db.Column(db.String(64), index=True, unique=True)
password = db.Column(db.String(120), index=True, unique=True)
email = db.Column(db.String(120), index=True, unique=True)
def __repr__(self):
return '<User %r>' % (self.nickname)
def set_password(self, password):
self.password_hash = generate_password_hash(password)
def check_password(self, password):
return check_password_hash(self.password_hash, password)
Route Приёма:
@app.route('/register', methods=['GET', 'POST'])
def register():
print("Logging")
if current_user.is_authenticated:
print("auth")
return redirect(url_for('index'))
form = RegisterForm()
print("Form")
if form.is_submitted():
user = tools.db.User(nickname=form.username.data, email=form.email.data, password=form.password.data)
user.set_password(form.password.data)
db.session.add(user)
db.session.commit()
flash('Вы зарегистрированы!')
print("login")
return redirect(url_for('login'))
print("Register")
return render_template('register.html', title='Регистрация', form=form)
И сама форма:
class RegisterForm(FlaskForm):
username = StringField('Nickname', validators=[DataRequired()])
email = StringField('Email', validators=[wtforms.validators.Email(), DataRequired()])
password = PasswordField('Password', validators=[DataRequired()])
submit = SubmitField("Register")
И когда регистрирую(Заполняю формы на /register и нажимаю Sumbit) он мне дают ошибку:
sqlite3.OperationalError: no such table: users
Как чинить?