Search code examples
pythonflaskflask-wtformswtforms

WTForms how to replace {{}} inside {{}}


I m pretty sure by title, this is unclear to you. Here is my code

{{wtf.quick_form(form, action='/edit?id={{id}}', method='POST')}}

Now I want to replace {{id}} with id that'll be passed to html page by flask but now, it is not replace {{id}} with the actual id(1) So how can I fix this? I use WtForms, python, Flask, Flaskform


Solution

  • You can concatenate the static part with the dynamic part.

    Use

    {{wtf.quick_form(form, action='/edit?id=' ~ id, method='POST')}}
    

    or

    {{wtf.quick_form(form, action='/edit?id=%s' % id, method='POST')}}