@app.route('/show-empty')
def show_empty():
res = Empty.query.all()
return render_template('empty.html', results=res)
@app.route('/remove-empty/<int:emp_id>')
def remove(emp_id):
Empty.query.filter(Empty.id == emp_id).delete()
db.session.commit()
flash('Updated Item!')
return redirect(url_for('show_empty'))
html:
<div>
<button> <a href="{{request.referrer}}"> Back </a> </button>
</div>
<br>
<table class="results-table">
<thead>
<tr>
<th>iaf</th>
<th>Name</th>
<th>Location</th>
<th class="button-column"></th>
</tr>
</thead>
<tbody>
{% if results %}
{% for res in results %}
<tr>
<td>{{ res.name }}</td>
<td>{{ res.loc }}</td>
<td>{{ res.iaf }}</td>
<td>
<form action="/remove-empty/{{ res.id }}">
<button>Remove</button>
</form>
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
so im using this to manage a display of empty items and for each item a button to remove from list, in the page i have a back button that uses request.referrer inside html template but if i press the button to remove something i assume it updates the referrer and the i cant go back to the same page i entered the display from any ideas on how to manage this?
New contributor
עידן בנזינו is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.