I am using SQLAlchemy along with Flask. I have a sign-up page(which I have named as login by mistake). I have used WTForms to create the sign-up page. If I submit details on the sign-up page, the details should get inserted into SQLite DB that I have created. When I execute my app, I dont get any error message. Everything seems fine, but by the end I dont find my entries in SQLite table.
The following is my login view:
@app.route('/login', methods=['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
t_name=form.Name.data
t_username=form.UserName.data
t_email=form.Email.data
t_password=form.Password.data
u = User(name=t_name,username=t_username,email=t_email,password=t_password)
db.session.add(u)
db.session.commit()
return render_template('login.html',form=form)
All fields in my Model(Users) are correct without typos.
The following is my login page template
{% extends "base.html" %}
{% block content %}
<h1>Sign Up</h1>
<form action="" method="post" name="login">
<p>
Name{{ form.Name(size=40) }}
{% for error in form.Name.errors %}
<span style="color: red;">[{{ error }}]</span>
{% endfor %}<br>
</p>
<p>
Username{{ form.UserName(size=40) }}
{% for error in form.UserName.errors %}
<span style="color: red;">[{{ error }}]</span>
{% endfor %}<br>
</p>
<p>
Email{{ form.Email(size=40) }}
{% for error in form.Email.errors %}
<span style="color: red;">[{{ error }}]</span>
{% endfor %}<br>
</p>
<p>
Password{{ form.Password(size=40) }}
{% for error in form.Password.errors %}
<span style="color: red;">[{{ error }}]</span>
{% endfor %}<br>
</p>
<p>
Confirm Password{{ form.ConfirmPassword(size=40) }}
{% for error in form.ConfirmPassword.errors %}
<span style="color: red;">[{{ error }}]</span>
{% endfor %}<br>
</p>
<p><input type="submit" value="Submit"></p>
</form>
{% endblock %}
Can anyone tell me what could be the possible mistake that I've done?
Aucun commentaire:
Enregistrer un commentaire