forms.py
# -*- coding: utf-8 -*-
from flask.ext.wtf import Form
from wtforms import TextField, SelectField
from wtforms.validators import Required
class WeatherAddForm(Form):
sost = SelectField("Состояние: ", choices=[
("ясно", "ясно"),
("пасмурно", "пасмурно"),
("туман", "туман"),
("дождь", "дождь"),
("снег", "снег")])
temp = TextField('Temp', [Required()])
views.py
...
def create():
form = WeatherAddForm()
if form.validate_on_submit():
rec = Weather(
sost = request.form['sost'],
temp = request.form['temp'])
db.session.add(rec)
db.session.commit()
flash(u'Сведения обновлены!')
return redirect(url_for('.index'))
...
return render_template("weather/create.html",
form = form)
В чем проблема?