0

Being am new to Flask I read the manuals of Flask an Jinja and I know how to read a filed from a template, but not how to update the template.

My template has the following structure which I modified from the doco

<form action="{{ url_for('add_entry') }}" method=post class=add-entry> <dl> <dt>Documet: <dd><input name=text size = 80 value = {{ AO_sDocument }} > </input > <dd><input type=submit value=Analyse> </dl> </form> 

and my Python has the following line

render_template('show_entries.html', AO_sDocument=AO_sDocument ) 

Yest this line does not seem to update the field.

Thanks!

2
  • I think you have some relevant portion of code missing in the snippet you posted. How is the variable AO_sDocument populated in python? Commented Jul 29, 2012 at 12:21
  • 4
    Is this example actually copied and pasted from your template? You do realise you're missing " around all your tag attributes (except action)? It wouldn't surprise me if AO_sDocument is valid, but the browser's not able to parse your example successfully. Commented Jul 29, 2012 at 12:21

1 Answer 1

2

As Jon Clements points out, your HTML has some markup errors. In order to guarantee all browsers can parse the HTML correctly, your template markup should look more like the following:

<form action="{{ url_for('add_entry') }}" method="post" class="add-entry"> <dl> <dt>Document:</dt> <dd><input name="text" size="80" value="{{ AO_sDocument }}" /></dd> <dd><input type="submit" value="Analyse" /></dd> </dl> </form> 

Alternately, you may wish to drop the use of <dl> and <dt> in favor of a <label>, which are ever so slightly more semantically correct:

<form action="{{ url_for('add_entry') }}" method="post" class="add-entry"> <label for="text">Document:</label> <input id="text" name="text" size="80" value="{{ AO_sDocument }}" /> <input type="submit" value="Analyse" /> </form> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.