当前位置: 动力学知识库 > 问答 > 编程问答 >

python - flask-peewee redirect to login page when registering is successful

问题描述:

after registration instead of redirecting to login am getting this error

UserDoesNotExist: Instance matching query does not exist:

SQL: SELECT "t1"."id", "t1"."username", "t1"."email", "t1"."password", "t1"."is_admin" FROM "user" AS t1 WHERE ("t1"."email" = %s)

PARAMS: [u'[email protected]']

here is my views.py file

@app.route('/register', methods=('GET', 'POST'))

def register():

form = forms.RegisterForm()

if form.validate_on_submit():

if models.User.get(models.User.email == form.email.data):

flash("user with the same email already exist")

else:

flash('you registered', "success")

models.User.create_user(

username=form.username.data,

email=form.email.data,

password=form.password.data)

return redirect(url_for('login'))

return render_template('register.html', form=form)

分享给朋友:
您可能感兴趣的文章:
随机阅读: