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 trialAnders Axelsen
3,471 PointsHow do I render the taco.html, when clicking "Add new taco"?
At this point, I have no errors. I do have infunctionalities, though.
Nothing happens, when I click "Add new taco".
- Is this because of taco.html not being integrated in some script?
I have appended a snapshot of the related workspace.
Cheers from the Danish summer. (lots of rain, happy trees)
1 Answer
Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Anders
The route '/taco' which creates a new taco, shouldn't this go to 'taco.html' on a GET request?
# my code
# i think your code should look like this
@app.route('/taco', methods=("GET", "POST"))
@login_required
def taco():
form = forms.TacoForm()
if form.validate_on_submit():
models.Taco.create(
protein=form.protein.data,
cheese=form.cheese.data,
shell=form.shell.data,
extras=form.extras.data,
user=g.user.id
)
flash("A taco has been born.", "success")
return redirect(url_for('index'))
return render_template('taco.html', form=form)
let me know if this fixes the issue
Anders Axelsen
3,471 PointsAnders Axelsen
3,471 PointsThank you Andreas!
It totally worked. :-)
But I did have to remove one level of indentation in your script :-)
Kind regards.