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 trial

Python Build a Social Network with Flask Broadcasting Lunch Order Form

Josip Dorvak
Josip Dorvak
18,126 Points

Not 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

forms.py
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()]
    )
lunch.py
@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
Joshua Edwards
52,175 Points

you misspelled validate in the if statement

Joshua Edwards
Joshua Edwards
52,175 Points

you also need to pass the form variable into the view by setting form=form in the view

Josip Dorvak
Josip Dorvak
18,126 Points

wow haha thanks alot. Can't believe I missed that >.<

Joshua Edwards
Joshua Edwards
52,175 Points

It 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
Josip Dorvak
18,126 Points

No thats not it, I think it indented weirdly when I posted the question.