1
私はフラスコと一緒にSQLiteを試していますが、私はエントリを追加してそれをすべて表示しました。今私は私の削除機能に立ち往生しています。だから私は助けを求めることを試みることを考え出した。ここに私のアルゴリズムです:フラスコSQLite SQalchemy ID番号でエントリを削除する
@app.route('/deleted', methods = ['GET', 'POST'])
def deleted():
if request.method == 'POST':
if not request.form['id']:
flash('Please enter the right number!','error')
else:
student1 = Students(request.form['id'])
x = Students.query.filter_by(id=student1)
db.session.delete(x)
db.session.commit()
flash('Record was deleted successfully ')
return redirect(url_for('show_all'))
return render_template('deleted.html')
、ここでは私のHTMLです:私が間違っていたところ
<!DOCTYPE html>
<html>
<body>
<h3>S Kickout the student</h3>
<hr/>
{%- for category, message in get_flashed_messages(with_categories = true) %}
<div class = "alert alert-danger">
{{ message }}
</div>
{%- endfor %}
<form action = "/deleted/{{id}}" method = "post">
<label for = "id">Id Number</label><br>
<input type = "text" name = "id" placeholder = "Student Id" /><br>
<input type = "submit" value = "Delete" />
</form>
</body>
</html>
誰が私を伝えることができますか?私はそれを理解することはできません。それは簡単ですが、私はなぜ私が見つからないのかを知るだけではありません。私のlocalhostでエラーが発生しました。どんな助けもありがとう。私はどこにも行きません。