i'm trying to update a value in my database in another html page called update.html when i go to update page for the first time it has the value first i assign (which make sense) after updating successfully it go back to home.html and shows the updated value in home.html but if i go to update that value again the title of the update.html and also the placeholder of the input tag in it is still the first value i assign (and also if i do it 10 times still is) how can i update the title and placeholder after updating value? this is my update.html:
{% extends "base.html" %} {% block title %}{{bars.data}}{% endblock %}{% block content %}
<div class="form">
<form action="/update/{{bars.id}}" method = "POST" >
<input type="text" name = "ferestandee" id = "ferestandee" placeholder="{{bars.data}}" ><br/><br/>
<div align = "center">
<input type="submit" class="btn btn-primary" value="update">
</div>
</form>
</div>
{% endblock %}
this is my home.html :
{% extends "base.html" %} {% block title %}Home{% endblock %}{% block content %}
<h1 align = "center">NOTES<h1>
<ul class = "list-group list-group-flush" id = "notes">
{% for bars in user.barnames %}
<li class = "list-group-item">
<h1 name="barnameId" id="barnameId" > {{ bars.data }} </h1>
<div align="right">
<a href="/delete/{{bars.id}}">
<button type = "button" class="btn btn-primary">Delete</button></a>
<a href="/update/{{bars.id}}" method="POST">
<input type="button" class = "btn btn-primary" value="update" > </a>
</div>
</li>
{% endfor %}
{% endblock %}
this is my models :
class Barname(db.Model):
__tablename__ = "barnamees"
id = db.Column(db.Integer, primary_key=True)
data = db.Column(db.String(10000))
date = db.Column(db.String(10000))
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
and this is my update func:
@views.route("/update/<int:id>" , methods = [ "GET" , "POST"])
@login_required
def update(id):
bars = Barname.query.get_or_404(id)
if request.method == "POST" :
bars.data= request.form["ferestandee"]
try:
db.session.commit()
flash ("updated successfully" , category = "success")
return render_template("home.html" , user = current_user ,bars = bars)
except :
flash ("something went wrong" , category = "error")
return render_template("home.html" , user = current_user)
else :
flash("method was get" , category = "error")
return render_template("update.html" , user = current_user , bars=bars )
i'm new to coding so if my question is dumb really sorry