Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJosip Dorvak
18,126 PointsNot Sure What I'm Doing Wrong Here
Not sure I understand the question properly. I'm certain I almost got it right, but it keeps saying I'm getting it wrong. Maybe someone can help me on this
from flask_wtf import Form
from wtforms import StringField, PasswordField, TextAreaField, DateField
from wtforms.validators import DataRequired, Email, Length
class SignUpInForm(Form):
email = StringField(validators=[DataRequired(), Email()])
password = PasswordField(validators=[DataRequired(), Length(min=8)])
class LunchOrderForm(Form):
order = TextAreaField(
validators=[DataRequired()]
)
date = DateField(
validators = [DataRequired()]
)
@app.route('/order', methods = ("GET","POST"))
def order_lunch():
form = forms.LunchOrderForm()
if form.valiate_on_submit():
models.LunchOrder.create(
date=form.date.data,
order=form.order.data,
user= g.user._get_current_object()
)
return render_template('lunch.html')
2 Answers
Joshua Edwards
52,175 Pointsyou misspelled validate in the if statement
Joshua Edwards
52,175 PointsIt looks like your if statement might be incorrectly indented on the lunch.py script. You don't need to indent the if after declaring your form.
Josip Dorvak
18,126 PointsNo thats not it, I think it indented weirdly when I posted the question.
Joshua Edwards
52,175 PointsJoshua Edwards
52,175 Pointsyou also need to pass the form variable into the view by setting form=form in the view
Josip Dorvak
18,126 PointsJosip Dorvak
18,126 Pointswow haha thanks alot. Can't believe I missed that >.<