I was first using Flask bootstrap and it worked
{% import "bootstrap/wtf.html" as wtf %}
<form method="POST" action="{{url_for('edit_ad', id=ad.id)}}" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ wtf.form_field(form.title) }}
{{ wtf.form_field(form.body) }}
{{ wtf.form_field(form.img_url) }}
{{ wtf.form_field(form.price) }}
<div>
<p>
<button class="" type="submit" value="Edit">Edit</button>
</p>
</div>
</form>
But I wanted to change it to Bootstrap Flask and use render_form. I'm having trouble with url_for
{% from 'bootstrap/form.html' import render_form %}
{{ render_form(form, action="{{url_for('edit_ad', id=ad.id)}}", method="POST", button_map={'edit_button': 'primary'}) }}
Here is my view:
@app.route('/edit_ad/<string:id>', methods=['GET', 'POST'])
@login_required
def edit_ad(id):
# more code
return render_template('edit_ad.html', form=form, ad=ad)
How should I pass id? Thanks
{{ad.id}}
` it renders correct number – ble Jun 24 '21 at 18:27