I am new to web development using the Flask and Jinja2 templates. One column in a row of my HTML table in a template:
<td><a> href="/plot?label={{stats[0]}}">{{stats[0]}} </a></td>
stats[0]is a variable that is a string and can contain '&' for example, Eggs and Spam. Now in the view (views.py):
@app.route("/plot", methods = ["GET", "POST"])
@login_required
def on_plot():
data = request.args
label_name = data['label']
In this case, I get datahow ImmutableMultiDict([(' Spam', u''), ('label', u'Eggs ')])
that is not true. Instead i wantImmutableMultiDict([('label', u'Eggs & Spam ')])
So how do I handle this case? I tried to do {{stats[0]|escape}}, but it does not work.
source
share