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 Tacocat Challenge The Challenge

Anders Axelsen
Anders Axelsen
3,471 Points

How 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

Hi 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
Anders Axelsen
3,471 Points

Thank you Andreas!

It totally worked. :-)

But I did have to remove one level of indentation in your script :-)

Kind regards.