Forums

Unable to download my requirements.txt

When I run this piece of code:

from collections import namedtuple from wtforms import Form, IntegerField, FieldList, FormField, TextField from werkzeug.datastructures import MultiDict

Prediction = namedtuple('Prediction', ['id'])

predictions = [Prediction(id=1), Prediction(id=2)]

class PredictionForm(Form): id = IntegerField() home = TextField() away = TextField()

class PredictionListForm(Form): predictions = FieldList(FormField(PredictionForm))

form = PredictionListForm(data=MultiDict({'predictions': predictions}))

print form.predictions()

The output is <ul id="predictions"></ul> instead of :

<ul id="predictions"> <li> <label for="predictions-0">Predictions-0</label> <table id="predictions-0"> <tr> <th><label for="predictions-0-id">Id</label></th> <td><input id="predictions-0-id" name="predictions-0-id" type="text" value="1"></td> </tr> <tr> <th><label for="predictions-0-home">Home</label></th> <td><input id="predictions-0-home" name="predictions-0-home" type="text" value=""></td> </tr> <tr> <th><label for="predictions-0-away">Away</label></th> <td><input id="predictions-0-away" name="predictions-0-away" type="text" value=""></td> </tr> </table> </li> <li> <label for="predictions-1">Predictions-1</label> <table id="predictions-1"> <tr> <th><label for="predictions-1-id">Id</label></th> <td><input id="predictions-1-id" name="predictions-1-id" type="text" value="2"></td> </tr> <tr> <th><label for="predictions-1-home">Home</label></th> <td><input id="predictions-1-home" name="predictions-1-home" type="text" value=""></td> </tr> <tr> <th><label for="predictions-1-away">Away</label></th> <td><input id="predictions-1-away" name="predictions-1-away" type="text" value=""></td> </tr> </table> </li> </ul>