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 Flask Basics Templates and Static Files Template Inheritance

Potential Content Block Recognition Problem with Flask Template Inheritance Problem #2

For some reason, the challenge insists that the original content of index.html isn't wrapped by a Jinga2 block declaration:

{% extends "layout.html" %}
{% block title %} Homepage {% endblock %}
{% block content %} 
<h1>Smells Like Bakin'!</h1>
<p>Welcome to my bakery web site!</p>
{% endblock  %} 

It seems it wants me to still wrap the content with the body element which would result in incorrect markup.

Perhaps Kenneth Love can clarify the error I'm getting?

flask_app.py
from flask import Flask
from flask import render_template

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')
templates/index.html
<!doctype html>
<html>
<head><title>Homepage</title></head>
<body>
<h1>Smells Like Bakin'!</h1>
<p>Welcome to my bakery web site!</p>
</body>
</html>
templates/layout.html
<!doctype html>
<html>
<head><title>Smells Like Bakin'</title></head>
<body>

</body>
</html>

Hi, I don't know or anything but I just see that there are a lot of new ? errors? problems? I mean when I look at the forum , there are allways new errors that the person cant pass the code challenge.

Might it be treehouse ?or something? im just pointing it out because its unusual this week and last one .

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Another example of a just-a-bit-too-picky validation. I've loosened it up and your code gets passed that step for me now. I may need to re-evaluate how I'm testing the templates. Validating Python, HTML, and a template renderer all at once is proving to be a bit tricky :D