Skip to content

Instantly share code, notes, and snippets.

@nsfyn55
Last active August 29, 2015 14:02
Show Gist options
  • Save nsfyn55/039288a4c1a6dd6ca8ee to your computer and use it in GitHub Desktop.
Save nsfyn55/039288a4c1a6dd6ca8ee to your computer and use it in GitHub Desktop.
Stack Predictions Sample
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()
@nsfyn55
Copy link
Author

nsfyn55 commented Jun 5, 2014

Python 2.7.6

Flask==0.10.1
Jinja2==2.7.2
MarkupSafe==0.23
WTForms==2.0
WebOb==1.4
Werkzeug==0.9.4
itsdangerous==0.24
wsgiref==0.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment