Jinja2 Templates and Forms.
Here is the project Tourist Attractions:
https://www.codecademy.com/paths/build-python-web-apps-flask/tracks/introduction-to-flask/modules/flask-templates-and-forms/projects/tourist-attractions-app
I have created the following code:
@app.route("/add_location", methods=[“POST”])
def add_location():
AddLocationForm = add_form()
if AddLocationForm.validate_on_submit():
name = add_form.name.data
description = add_form.description.data
category = add_form.category.data
visit.add(name, description, category)
return redirect(url_for(“locations”, category=category))
I am getting a NameError stating that add_form is not defined. I have completed the project and was going to just move on but I figured I’d play with it a little first. I tried to use the form and submit a location but got the NameError. Am I doing something wrong? I’d like to correct it so I can feel that I REALLY got the project completed, if you know what I mean. Any help would be greatly appreciated!